-
Notifications
You must be signed in to change notification settings - Fork 12
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
Conversation
const _o18 = 1 | ||
type _o19 [_o18]uint8 | ||
const _o22 = 1 | ||
type _o23 [_o22]uint8 |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Now that #50 is merged we can add those tests back.
This is part 2 of #44, where we decompose expressions that contain function calls.