Skip to content

[DSLX] Support Self { ... } struct instances in IR conversion. - #5544

Draft
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1023922255
Draft

copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1023922255

Conversation

@copybara-service

Copy link
Copy Markdown

[DSLX] Support Self { ... } struct instances in IR conversion.

IR conversion assumed that the type of a struct instance is always a type
reference. Inside an impl it can also be Self (Self { field: ... } or
Self { ..self }), which made IR conversion crash even though type checking
and the interpreter accept the code. Resolve Self to the impl's struct, and
return an error instead of crashing on any other annotation kind.

Adds the impl_self_struct_instance DSLX language test (plain, splat, and
parametric struct cases), which converts to IR and checks IR equivalence.

IR conversion assumed that the type of a struct instance is always a type
reference. Inside an impl it can also be `Self` (`Self { field: ... }` or
`Self { ..self }`), which made IR conversion crash even though type checking
and the interpreter accept the code. Resolve `Self` to the impl's struct, and
return an error instead of crashing on any other annotation kind.

Adds the impl_self_struct_instance DSLX language test (plain, splat, and
parametric struct cases), which converts to IR and checks IR equivalence.

PiperOrigin-RevId: 1023922255

This branch has not been deployed

No deployments
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