Previously, `x = cos(x)` would just say "`x` is undefined". Now it says that `x` cannot be referenced in its own definition, try using a different variable instead. To do this, I've added a new `Option<String>` field to the mod-local executor context, tracking the current variable declaration. This means cloning some strings, implying a small performance hit. I think it's fine, for the better diagnostics. In the future we could refactor this to use a &str or store variable labels in stack-allocated strings like docs.rs/compact_str or something. Closes https://github.com/KittyCAD/modeling-app/issues/6072
3 lines
86 B
Plaintext
3 lines
86 B
Plaintext
// This won't work, because `x` is being referenced in its own definition.
|
|
x = cos(x)
|