Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DSLX:cleanup] Remove ConstantArray node from AST, it is misleading / not useful. #1753

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cdleary
Copy link
Collaborator

@cdleary cdleary commented Nov 29, 2024

Previously ConstantArray was trying to convey some type-system-level properties as imbued in an AST node, but it was not fully accurate, and generally only served to confuse things. This gets us back to where the AST just represents the parsed syntax and the typechecker figures out constexpr properties and annotates them in the type information. This also allows us to seal up the Array AST node as final — subclassing of AST nodes can be awkward, we generally use hierarchy in the AST very sparingly.

This reworks the deduce routine a bit to consolidate on the main discrepancy that was there between Arrays and ConstArrays, which was that we would, for user convenience, annotate the element type on any un-annotated numerical literals contained within the array. This will become better and more general will type inference 2.0 but until that comes we want to make sure we don’t have to change code in a sprawling way.

Just trying to tighten up invariants in advance of somebody investigating #1748

… not useful.

Previously ConstantArray was trying to convey some type-system-level properties
as imbued in an AST node, but it was not fully accurate, and generally only
served to confuse things. This gets us back to where the AST just represents
the parsed syntax and the typechecker figures out constexpr properties and
annotates them in the type information. This also allows us to seal up the
Array AST node as final  — subclassing of AST nodes can be awkward, we
generally use hierarchy in the AST very sparingly.

This reworks the deduce routine a bit to consolidate on the main discrepancy
that was there between Arrays and ConstArrays, which was that we would, for
user convenience, annotate the element type on any un-annotated numerical
literals contained within the array. This will become better and more general
will type inference 2.0 but until that comes we want to make sure we don’t have
to change code in a sprawling way.

Just trying to tighten up invariants in advance of somebody investigating
google#1748
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant