Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject quoted local variables #210

Closed
erkyrath opened this issue Apr 23, 2023 · 2 comments
Closed

Reject quoted local variables #210

erkyrath opened this issue Apr 23, 2023 · 2 comments

Comments

@erkyrath
Copy link
Contributor

Some ancient version of Inform imagined it was a good idea to quote your local variables:

[ MyTest "x";
  return x+1;
];

You can use this to define local variables which are not symbols, which is entirely useless as far as I can tell -- you can't use them in expressions or statements.

[ MyTest "!" "x+1";
  return x+1;   ! error because there is no variable "x"
];

I would like to get rid of this pointless feature. In theory this might break some previously-valid code, like the first example above, but I bet it doesn't.

@erkyrath
Copy link
Contributor Author

This should just be a matter of removing the if (token_type != DQ_TT) test in parse_routine().

@erkyrath
Copy link
Contributor Author

Update: aaaaaaaaaagggghhhhhh.

Ignoring quotes is a general behavior of get_next_token() when dont_enter_into_symbol_table is true. Which means that this inconsistency turns up in lots of places! All of the following compile without error:

Switches v5;
Switches "v5";

Verb 'foo' * -> "Acting";

[ TestMe foo "bar";
    <"Acting">;
];

I think that's everywhere we parse a symbol with dont_enter_into_symbol_table set. (There's places where we use it but don't parse symbols, e.g., code that is #if'd out.)

It should be okay to reject quoted symbols in all of these cases. Except maybe the Strings directive? But that's explicitly deprecated now, with a warning.

Conclusion: I am going to remove this general behavior -- get_next_token() should distinguish between quoted strings and bare-strings. All the above cases will only accept bare-strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants