Skip to content

Effects typechecking fixes #1216

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

Merged
merged 3 commits into from
May 5, 2025
Merged

Effects typechecking fixes #1216

merged 3 commits into from
May 5, 2025

Conversation

rajdakin
Copy link
Contributor

@rajdakin rajdakin commented Apr 23, 2025

This PR fixes two issues:

  • If one kind of unification issue related to effects occurs, the old links tries to generate an error message but the content of that error message generates an internal error;
  • If linearity is not tracked, lindo should be parsed exactly the same as do and case <Foo =@ k> like case <Foo => k>.

MWE:

sig f : () {A:() =@ Bool|_}~> Bool
fun f() { lindo A() }

This MWE generates the error in the old links when it is supposed to be correct.
Note that removing the signature of f makes it work regardless of the fix, as the type will be automatically inferred with a linear effect before linearity is dropped.

sig f : (s) {A:(s) {}-> () |_}-> ()
fun f(st) {do A(st)}

This MWE generates an internal error in the old links. The proposed fix transforms this internal error into the expected normal error:

test.links:2: Type error: Invocation of the operation
    `A(st)'
requires an effect context
    `() => (a) {}-> ()'
but, the currently allowed effect is
    `(a) => (a) {}-> ()'
In expression: do A(st).

@dhil dhil requested a review from thwfhk April 23, 2025 16:15
@rajdakin rajdakin changed the title Fixes related to lindo Effects typechecking fixes Apr 23, 2025
@thwfhk
Copy link
Contributor

thwfhk commented May 2, 2025

This PR looks good to me. I'm not entirely sure about the second MVE. I think (s) {}-> () is an old-fashioned way of writing effect signatures in Links, which used to be understood as an operation that takes an argument of type s and returns unit. @dhil is this feature completely discarded now?

@rajdakin
Copy link
Contributor Author

rajdakin commented May 2, 2025

I think (s) {}-> () is an old-fashioned way of writing effect signatures in Links,

It looks like the current parser reads this as () => (s) {}-> (), possibly due to some default sugar settings. Regardless, another MVE would be:

sig f : (s) {A:(Int) => () |_}-> ()
fun f(st) {do A(st)}

The main issue is that the effect arguments are not what is expected (here s instead of Int), so an error is generated, which then triggers an internal error due to the wrong value being passed as the argument to an internal function.

@thwfhk
Copy link
Contributor

thwfhk commented May 5, 2025

That makes sense to me. I agree with you that these are two orthogonal issues.

@thwfhk thwfhk merged commit 4333a8d into links-lang:master May 5, 2025
6 checks passed
@rajdakin rajdakin deleted the lindo_fix branch May 5, 2025 11:01
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