You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[inline]: a nested [inline] call taking a var struct parameter of the caller fails with 'local reference to non-local expression is unsafe' #11
An [inline] function whose body binds a value with let and then calls another [inline] function with its var struct parameter fails to compile with error[31019]: local reference to non-local expression is unsafe when it is called from a function that received the struct as a parameter. The same call from a local variable compiles and runs. Nothing in the source is unsafe.
Reproducer
optionsgen2structRt {
pc : int = 0
code : array<int>
stack : array<int>
}
[inline]
defnext_code(varrt : Rt) : int {
letv=rt.code[rt.pc]
rt.pc++returnv
}
[inline]
defat(rt : Rt; i : int) : int {
returnrt.stack[i]
}
[inline]
defread(varrt : Rt) : int {
leti=next_code(rt)
returnat(rt, i)
}
defop(varrt : Rt) : int {
returnread(rt)
}
[export]
defmain() {
varrt=Rt()
push(rt.code, 1)
push(rt.stack, 7)
push(rt.stack, 9)
print("{op(rt)}\n")
}
Observed / expected
variant
result
as above
error[31019]: local reference to non-local expression is unsafe at return at(rt, i)
read body as one expression return at(rt, next_code(rt))
same error
main calls read(rt) on its local rt instead of op(rt)
prints 9
options disable_inline
prints 9
Expected 9 in every variant.
Tested on 69a5896 (v0.6.4-481) and 388691e, interpreter, no project file.
Fixed upstream: GaijinEntertainment#4235 is closed and the fix is in master abf1d40e35 (0.6.5). Verified by running this issue's repro on a build of that commit.
Activity
eden: optional operation fusion (op + op_SetSlot_i32), off by default
lookibed commentedon Nov 9, 2026
Re-checked by the owner from this issue's reproducer on daScript abf1d40 (0.6.5): fixed upstream (GaijinEntertainment/daScript 2131620 GaijinEntertainment#4472 dasLLVM, 1404d5a GaijinEntertainment#4480 optimizer, f386f92 GaijinEntertainment#4482 cache and tools). The c2das-re probes were re-pinned in the repin PRs (lookibed/c2das-re#142-GaijinEntertainment#147; ruling 38 addendum 4).
lookibed commentedon Nov 9, 2026
Fixed upstream: GaijinEntertainment#4235 is closed and the fix is in master
abf1d40e35(0.6.5). Verified by running this issue's repro on a build of that commit.