php icon indicating copy to clipboard operation
php copied to clipboard

Remove reference-or-not inconsistencies when manipulating AST objects

Open gleamingthecube opened this issue 9 years ago • 2 comments

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.

gleamingthecube avatar Aug 02 '15 08:08 gleamingthecube

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.

krageon avatar Nov 14 '15 19:11 krageon

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.

stephens2424 avatar Nov 25 '15 05:11 stephens2424