Ambiguity between pointer types and deref expressions
MovingtoMars opened this issue · comments
How will this be handled? Go does it by using StarExpr
for both. Then again, Go also treats types as Expr
in the AST, so that might not work. https://github.com/golang/go/blob/master/src/go/ast/ast.go#L327
My guess is that we'll store temporarily store star expressions in a special enum or struct that can be either, and differentiate them once we have enough context.
Hmm, looks like the best move could be to copy Go and store Type in the Expr enum, then check it in semantic analysis.
Something I don't understand in the approach used by Go's authors is, why are types treated as expressions? To me, that doesn't make sense; AFAIK, a type may not appear where an expression is expected, so why make that possible? To make the compilation code simpler? I'm all for simplicity, but unless there is a valid technical justification for doing this, I think this is the wrong approach.