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

Fix glue generation of main : Effect Str #5688

Closed
wants to merge 8 commits into from
Closed

Conversation

rtfeldman
Copy link
Contributor

We hit an edge case with this, which is that glue would unwrap the opaque Effect type and see that it's a function (because Effect is an opaque wrapper around a function), and therefore not generate a thunk for main.

Comment on lines +1223 to +1226
// TODO investigate: is LambdaSetId(1) always correct here?
// It's supposed to be the LambdaSetId for this thunk,
// but what LambdaSetId should that be, if not 1?
extern_name: fn_caller_name(&name, LambdaSetId(1)),
Copy link
Member

Choose a reason for hiding this comment

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

this should indeed be correct because thunks only dispatch to one destination, and more over only have place in their type that they can dispatch

Comment on lines +120 to 126
if is_function(env.subs, var) {
types.entry_points.push((name, id));
entry_points.remove(&k);
} else {
// This top-level value isn't a function, so we will end up code-genning a thunk
// for it. We need to represent that thunk explicitly in glue!
env.add_thunk_entry_point(&mut types, name, id);
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this logic is correct. Wouldn't the following program run into the same issue?

mainImpl1 = \{} -> ""
mainImpl2 = \{} -> ""

mainForHost : {} -> Str
mainForHost = if Bool.true then mainImpl1 else mainImpl2

This would hit the first branch on 120, but mainForHost should also be a thunk here.

@github-actions
Copy link

github-actions bot commented Sep 2, 2023

Thank you for your contribution! Sometimes PRs end up staying open for a long time without activity, which can make the list of open PRs get long and time-consuming to review. To keep things manageable for reviewers, this bot automatically closes PRs that haven’t had activity in 60 days. This PR hasn’t had activity in 30 days, so it will be automatically closed if there is no more activity in the next 30 days. Keep in mind that PRs marked Closed are not deleted, so no matter what, the PR will still be right here in the repo. You can always access it and reopen it anytime you like!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants