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

Desugar expressions (part 2) #50

Merged
merged 6 commits into from
Sep 21, 2023
Merged

Desugar expressions (part 2) #50

merged 6 commits into from
Sep 21, 2023

Conversation

chriso
Copy link
Contributor

@chriso chriso commented Sep 20, 2023

This is part 2 of #44, where we decompose expressions that contain function calls.

const _o18 = 1
type _o19 [_o18]uint8
const _o22 = 1
type _o23 [_o22]uint8
Copy link
Contributor

@achille-roussel achille-roussel Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize this earlier but we may have to try to perserve type names because those will be visible to the program via reflect.TypeOf(...).Name(), by changing it we might break some programs.

It gets tricky if the type is used in a struct field etc... I know it's difficult due to the shadowing rules, we'll have to be creative :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's look at this in a follow-up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We hoist the type decls because the dispatch control flow means that their definition might be moved into a new scope and not be accessible to subsequent statements.

What we could do is not hoist type decls to the function prologue, and not rename them (since we don't have to worry about name clashes at the top-level anymore), and instead handle type decls when building the dispatch control flow. Since types can be shadowed within the same block, we can't hoist type decls into a "block prologue". Maybe when introducing new dispatch scopes we'll need to copy applicable type decls into that inner scope?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, we have options. Declaring the original types in places where they were supposed to exist and then doing late type conversion could work well 👍 If I remember correctly Go accepts type conversions when the memory layouts are compatible.

@chriso chriso merged commit ff13c7c into main Sep 21, 2023
2 checks passed
@chriso chriso deleted the decompose-expressions branch September 21, 2023 02:04
achille-roussel added a commit that referenced this pull request Sep 21, 2023
Now that #50 is merged we can add those tests back.
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.

2 participants