Closed katjonathan closed 4 years ago
If you're asking whether the interpreter should allow it, the answer is yes. Lox treats all variables as mutable and function declarations are just syntactic sugar for variable bindings.
If you're asking whether that's a good language design choice for Lox... it's debatable. But doing this way keeps the interpreter simpler and avoids the need to track which identifiers are bound to functions and which to variables at compile time. It's working as intended. :)
Clox seems happy to compile something like this, despite
dummy
referring to a function name and not a variable:Should this be allowed?