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
Apart from a run method, all the Q::Statement:: types have a declare method which gets called on the surrounding block's entry.
This method is a hack. More exactly, it was added at a time when we were running only off ASTs, without the parser creating static lexpads for us. Now that it does, the declare methods are superfluous and should be removed.
The interesting thing, though, is that if we just go ahead and remove all the declare methods, a lot of tests in t/semantics/ start failing. This is because the ASTs in these tests were never program text to begin with, and so they never got the static lexpads from the parser that would replace the declare method hacks.
To remedy this, we want to create a new helper routine check in _007::Test that traverses an AST and initializes static lexpads in the same way a parser would. Essentially doing a "parse" of the AST.
Note that we can cheat quite a bit in writing this routine, as we don't have to worry about erroneous conditions in the AST. (The name check primarily means "do stuff that belongs at CHECK time", not "make sure everything's OK".) We can assume the test author wrote a correct AST for the test, otherwise it's a bad test. As far as I can see, we only have to initialize the static lexpads. Then we can remove the declare methods.
Interestingly, the way we seem to be headed with synthetic ASTs (which were created using Q:: constructors in program code somewhere) is that these will also need a similar check routine. So it's probable that this routine actually becomes core, not just a test helper. At that point though, we do need to check everything the parser checks, because we don't trust the user the way we trust the test author.
The text was updated successfully, but these errors were encountered:
Apart from a
run
method, all theQ::Statement::
types have adeclare
method which gets called on the surrounding block's entry.This method is a hack. More exactly, it was added at a time when we were running only off ASTs, without the parser creating static lexpads for us. Now that it does, the
declare
methods are superfluous and should be removed.The interesting thing, though, is that if we just go ahead and remove all the
declare
methods, a lot of tests int/semantics/
start failing. This is because the ASTs in these tests were never program text to begin with, and so they never got the static lexpads from the parser that would replace thedeclare
method hacks.To remedy this, we want to create a new helper routine
check
in_007::Test
that traverses an AST and initializes static lexpads in the same way a parser would. Essentially doing a "parse" of the AST.Note that we can cheat quite a bit in writing this routine, as we don't have to worry about erroneous conditions in the AST. (The name
check
primarily means "do stuff that belongs atCHECK
time", not "make sure everything's OK".) We can assume the test author wrote a correct AST for the test, otherwise it's a bad test. As far as I can see, we only have to initialize the static lexpads. Then we can remove thedeclare
methods.Interestingly, the way we seem to be headed with synthetic ASTs (which were created using
Q::
constructors in program code somewhere) is that these will also need a similarcheck
routine. So it's probable that this routine actually becomes core, not just a test helper. At that point though, we do need to check everything the parser checks, because we don't trust the user the way we trust the test author.The text was updated successfully, but these errors were encountered: