Closed OAGr closed 3 months ago
Hm... getting weird errors:
dontUseThisVar = 34
spec1 = Spec.make(
{name: "rst", documentation: "rstrts", validate: {|f| f} }
)
spec1_copy = spec1
@spec(spec1)
bar = 3
Here, it seems to think the spec1
reference refers to dontUseThisVar
.
However, in this case, when I make a copy of spec1
, it works:
dontUseThisVar = 34
spec1 = Spec.make(
{name: "rst", documentation: "rstrts", validate: {|f| f} }
)
spec1_copy = spec1
@spec(spec1_copy)
bar = 3
I did some more digging. Seems like the following fails:
name = "MyName"
@name(name)
foo = 3
When I run testCompile
on it, I get:
['(Assign name "MyName")', "(Assign foo (Call Tag.name 3 (StackRef 1)))"]
The problem is that it's using StackRef 1
instead of StackRef 0. This is a mistake.
Looking back, v0.9.3 seems fine. It seems like this bug was introduced in this PR: https://github.com/quantified-uncertainty/squiggle/pull/3054
Which makes sense, as it did change a lot of code around this area.
With a bit more digging, it seems likely like the problem is with compile.ts
. specifically around the DecoratedStatement
case. I'm not sure how to fix it though, tried a few things, nothing really helped (without breaking other stuff). It would take me much longer to fully understand.
Description of suggestion or shortcoming:
Interestingly enough, this below works: