Skip to content

Commit df5a908

Browse files
nsicchaclaude
andcommitted
fix: rewrite property references in kwarg defaults of indexed properties
Kwarg default expressions in indexed property signatures (e.g. `bar(idx; limit=min(200, n))`) were not passed through walk_rhs, leaving bare property references that caused UndefVarError at runtime. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f2037ee commit df5a908

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/DynamicObjects.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,10 +1123,23 @@ dynamicstruct(expr; docstring=nothing, cache_type=:serial, child_handler=nothing
11231123
# the method body — Julia uses the body's first LNN for
11241124
# Method.file/line, which must point at user code.
11251125
_lnn = something(info.lnn, LineNumberNode(0, :unknown))
1126+
walked_indices = map(info.indices) do idx
1127+
if Meta.isexpr(idx, :parameters)
1128+
Expr(:parameters, map(idx.args) do a
1129+
if Meta.isexpr(a, :kw)
1130+
Expr(:kw, a.args[1], walk_rhs(a.args[2]; info.locals, properties, lnn=info.lnn))
1131+
else
1132+
a
1133+
end
1134+
end...)
1135+
else
1136+
idx
1137+
end
1138+
end
11261139
_call(f, extras...) = fixcall(Expr(:call,
11271140
Expr(:., DynamicObjects, QuoteNode(f)),
11281141
:(__self__::$type), :(::Val{$(Meta.quot(name))}),
1129-
info.indices..., Expr(:parameters, extras...),
1142+
walked_indices..., Expr(:parameters, extras...),
11301143
))
11311144
iscached_val = Symbol("@cached") in info.macros
11321145
Expr(:block,

0 commit comments

Comments
 (0)