Skip to content

Commit a3f336f

Browse files
nsajkoaviatesk
andauthored
fix handling of unknown setting in @constprop, fix error message (#56946)
Co-authored-by: Shuhei Kadowaki <[email protected]>
1 parent 89afe20 commit a3f336f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

base/expr.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,14 @@ macro constprop(setting)
401401
end
402402

403403
function constprop_setting(@nospecialize setting)
404+
s = setting
404405
isa(setting, QuoteNode) && (setting = setting.value)
405406
if setting === :aggressive
406407
return :aggressive_constprop
407408
elseif setting === :none
408409
return :no_constprop
409410
end
410-
throw(ArgumentError(LazyString("@constprop "), setting, "not supported"))
411+
throw(ArgumentError(LazyString("`Base.@constprop ", s, "` not supported")))
411412
end
412413

413414
"""

test/misc.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,3 +1612,15 @@ let errs = IOBuffer()
16121612
'`, devnull, stdout, errs)
16131613
@test occursin("disable_new_worlds", String(take!(errs)))
16141614
end
1615+
1616+
@testset "`@constprop`, `@assume_effects` handling of an unknown setting" begin
1617+
for x ("constprop", "assume_effects")
1618+
try
1619+
eval(Meta.parse("Base.@$x :unknown f() = 3"))
1620+
error("unexpectedly reached")
1621+
catch e
1622+
e::LoadError
1623+
@test e.error isa ArgumentError
1624+
end
1625+
end
1626+
end

0 commit comments

Comments
 (0)