php
php copied to clipboard
Remove reference-or-not inconsistencies when manipulating AST objects
Several places in the code look for ast.Foo but also *ast.Foo. Example in ast/printer/printer.go:
case ast.AssignmentExpression:
p.PrintAssignmentExpression(&n)
case *ast.AssignmentExpression:
p.PrintAssignmentExpression(n)
At the end of the day we are not sure about the kind of object inside in AST.
When I get access to my private keys I will see about uploading a MR that at least fixes the printer - all it really does is replace every case of the switch/case with both a bald case and a pointer case (with corresponding & or not). It's not beautiful but it does perfectly get around the incredibly annoying problem of not being able to output some nodes sometimes, which is the issue I was trying to solve.
I think migrating toward pointers for all the node types will be the long term goal, but accepting both in the printer type switch seems like a good idea, especially in the short term.