ulfalizer/Kconfiglib

Prompt shown even when expected to be disable.

tejlmand opened this issue · 0 comments

Problem description

When a symbol is double defined but with different prompts, where the active prompt is depending on a common setting both prompts may show.
For example to indicate to users that a given setting is EXPERIMENTAL under some circumstances, one prompt is shown when FOO is enabled also, and the other prompt is shown when FOO is disabled.

This happens when configs right below the second symbol is guarded (depends on) with an if.

Code that reproduces this:

config FOO
        bool "FOO"
        default n
        bool

config BAR
        bool "bar" if !FOO

config BAR
        bool "bar [EXPERIMENTAL]" if FOO

if BAR

config BAZ
        bool "Baz is here"

endif

As expected
image

Unexpected, both prompts are now shown:
image

Expected behavior

Only a sing prompt should be shown when FOO=n and BAR=y

Workaround

Add a DUMMY config between the last config and the if, like this:

config FOO
        bool "FOO"

config BAR
        bool "bar" if !FOO

config BAR
        bool "bar [EXPERIMENTAL]" if FOO

config DUMMY
        bool

if BAR

config BAZ
        bool "Baz is here"

endif

Almost as before:
image

Now working as expected:
image

Cons on the workaround

BAZ setting is no longer indented as it is no longer seen as a submenu to BAR.

Additional info

This code is believed to be responsible for the observed behavior:

Kconfiglib/menuconfig.py

Lines 1504 to 1513 in 061e71f

elif node.list and isinstance(node.item, Symbol):
# Show invisible symbols if they have visible children. This
# can happen for an m/y-valued symbol with an optional prompt
# ('prompt "foo" is COND') that is currently disabled. Note
# that it applies to both 'config' and 'menuconfig' symbols.
shown_children = rec(node.list)
if shown_children:
res.append(node)
if not node.is_menuconfig:
res += shown_children