~technomancy/fennel#101: 
Mangling affects strict global checking in REPL

I'm not sure how exactly this should work but the current behavior is probably inaccurate:

Welcome to Fennel 1.0.0-dev on Lua 5.4!
Use ,help to see available commands.
Try installing readline via luarocks for a better repl experience.
>> (tset _G :foo (fn [] (print :foo)))
nil
>> (foo)
foo
>> (tset _G :foo-bar (fn [] (print :foo-bar)))
nil
>> (foo-bar)
runtime error: global '__fnl_global__foo_2dbar' is not callable (a nil value)
stack traceback: ...
Status
RESOLVED FIXED
Submitter
~andreyorst
Assigned to
No-one
Submitted
2 months ago
Updated
2 months ago
Labels
No labels applied.

~technomancy 2 months ago

There's definitely a bug here, but the bug is that the first one works, not that the second one doesn't.

Using the _G table is more or less a way to bypass the strict globals checking, since it's just table access. If you want to set a global in a way that participates in strict globals checking, you use the global special.

(global foo-bar (fn [] (print :foo-bar)))
(foo-bar)
foo-bar

This works fine. However, the first one should not work at all; it looks like somehow strict globals checking stopped working in the repl.

~andreyorst REPORTED FIXED 2 months ago

However, the first one should not work at all; it looks like somehow strict globals checking stopped working in the repl.

I agree. This was fixed in a11d3658

Register here or Log in to comment, or comment via email.