- Notifications
You must be signed in to change notification settings - Fork0
Make names declared as constants immutable#13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
arsalan0c commentedFeb 14, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
We might need another way to automatically test this due to the inability to catch errors in Source |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
We could add some data structure (at the global level) and use it to track errors. And then inspect it in the tests. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
arsalan0c commentedFeb 17, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Could you clarify how we could use a data structure to track errors? For example, if the following is a test then an error will be thrown due to constant reassignment. parse_and_eval("const x = 2; x = 4; x;");assert_equal(2,final_result); |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
add#12
This is done by storing an additional variable (
is_variable) which indicates whether a name was declared as a variable. When assigning a value to a name, the value of this variable is then checked. If it is true, (eg. for names declared withlet), then the assignment is allowed. Otherwise, an error is thrown.