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
Faulty code: don't permit undeclared by default #13286
Faulty code: don't permit undeclared by default #13286
Conversation
Hi, I have the impression that this is the entry point of most method compilation happening in the image no? |
For me, |
24baf68
to
5ab9b2d
Compare
Bootstrap passed 🎉, but test failed 😭 because I fumbled a rebase trying to restore some lost comments (cf #13246). So let's try again |
Tests are ok, Windows is still running, but who cares? |
This PR defaults
permitUndeclared
to false, meaning that unless instructed otherwise with the setterpermitUndeclared:
,OpalCompiler
will consider the (static) use of undeclared variables to be errors.Moreover,
OCUndeclaredVariableNotice
is officially promoted toRBErrorNotice
. Until now, it was in some limbo state, neither an error nor a warning. This change means that an AST node with such a notice will answer true toisFaulty
.In order for this change to be successful, the following clients are adapted:
TaAbstractComposition
sets permitUndeclaredMethodAddition
sets permitUndeclaredClassDescription>>compile:*
, that includes CodeImport and some tests in newtools, permitUndeclared is set according to a heuristic (is a requestor present) that is comparible with the current usage.I think that's the right move since I consider
ClassDescription>>compile:*
a legacy API, so maintaining its behavior make sense.Tests are also added.
RBCodeSnippet
gains a new ivarisFaultyMinusUndeclared
(the name is not nice, but it is not used that much) that correspond to being faulty, whilepermitUndeclared
is set to true.It is used for the Monticello test on snippets and for a new test explicitly made to check
permitUndeclared:
There are many small changes with specific goals, so there are a lot of commits (oneliner sometime).
The global diff is less big than I expected.