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
It would be nice if we implemented Lua 5.4 variable attributes in Pallene. We can start with <const>, which should be the easiest one to implement. When we get that working, it will pave the way for <close>.
localx<const>=2x=10-- this should be a compile-time error
The text was updated successfully, but these errors were encountered:
First step would be to teach the compiler how to parse the const declarations. We would have to modify the ast.lua, to add an extra field somewhere which says if a variable declaration is constant. (I haven't stopped to think about what node should get an extra field. Do you have a suggestion?). After this, we will have to modify the recursive descent parser in the parser.lua, to teach it how to parse the const declaration. This might be a good place for a first pull request.
The second pull request would be to modify the typechecker to enforce the requirement that the const variables are not reassigned.
It's normal if there are questions along the way, don't be afraid to ask.
For the type checking, a simple way could be to add a _is_const annotation / field to every symbol in the checker.
Then for assignment nodes, make sure no symbol in the LHS has the is_const annotation.
It would be nice if we implemented Lua 5.4 variable attributes in Pallene. We can start with
<const>
, which should be the easiest one to implement. When we get that working, it will pave the way for<close>
.The text was updated successfully, but these errors were encountered: