Describe the bug
The preprocessor allows testing if a macro is defined, via specific forms (-ifdef, -ifndef) as well as within macro condition evaluation with defined(..).
Special treatment for the built-in macros was introduced in 54dde00, bringing in a test is_macro_defined/2 that checks for a replacement of undefined, and reports false if so, as well as it not being in the macro table.
This is used in the processing of ifdef and ifndef, but not for defined(..), its code is unchanged from when it was introduced (109b1dc)
|
rewrite_expr({call,_,{atom,_,defined},[N0]}, #epp{macs=Macs}) -> |
|
%% Evaluate defined(Symbol). |
|
N = case N0 of |
|
{var,_,N1} -> N1; |
|
{atom,_,N1} -> N1; |
|
_ -> throw({bad,'if'}) |
|
end, |
|
{atom,0,maps:is_key(N, Macs)}; |
Is this difference expected, or was it overlooked when the others were changed?
Affected versions
It is in current master (
|
{atom,erl_anno:new(0),maps:is_key(N, Macs)}; |
)
Describe the bug
The preprocessor allows testing if a macro is defined, via specific forms (
-ifdef,-ifndef) as well as within macro condition evaluation withdefined(..).Special treatment for the built-in macros was introduced in 54dde00, bringing in a test
is_macro_defined/2that checks for a replacement ofundefined, and reportsfalseif so, as well as it not being in the macro table.This is used in the processing of
ifdefandifndef, but not fordefined(..), its code is unchanged from when it was introduced (109b1dc)otp/lib/stdlib/src/epp.erl
Lines 1153 to 1160 in 109b1dc
Is this difference expected, or was it overlooked when the others were changed?
Affected versions
It is in current master (
otp/lib/stdlib/src/epp.erl
Line 1676 in d459618