Currently the compiler IR doesn't distinguish between type-signature declarations and type-ascription expressions. As a result, when translating Tree.TypeSignature and Tree.TypeAnnotated the parser's distinction between these node types is lost, and later logic analyzing the IR makes an independent determination of whether to treat the node as a declaration or expression. To ensure the compiler's behavior is consistent with the AST, we should maintain the distinction made by the parser.
I don't think they should necessarily both be IR nodes:
If we attach information found in type-signature declarations to the corresponding bindings as a field, we could catch more errors than the current TypeSignature validation pass; it also might be more efficient to eliminate that pass.
I don't know enough about how type ascriptions are used to know whether they should be a node or a field on expressions.
Currently the compiler
IR
doesn't distinguish between type-signature declarations and type-ascription expressions. As a result, when translatingTree.TypeSignature
andTree.TypeAnnotated
the parser's distinction between these node types is lost, and later logic analyzing theIR
makes an independent determination of whether to treat the node as a declaration or expression. To ensure the compiler's behavior is consistent with the AST, we should maintain the distinction made by the parser.I don't think they should necessarily both be IR nodes: