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

Escaping Skolem variables lead to incorrect types #211

Closed
byorgey opened this issue Oct 11, 2021 · 1 comment
Closed

Escaping Skolem variables lead to incorrect types #211

byorgey opened this issue Oct 11, 2021 · 1 comment
Labels
Bug The observed behaviour is incorrect or unexpected. L-Type inference The process of inferring the type of a Swarm expression. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact.

Comments

@byorgey
Copy link
Member

byorgey commented Oct 11, 2021

Ilya Smirnov left a comment on my blog post about implementing Hindley-Milner with the unification-fd library pointing out a bug. Since the implementation of type inference for swarm-lang was taken more or less directly from that blog post, the bug exists in Swarm as well. It's a bit obscure and unlikely to be tripped over by casual players, but it's a bug nonetheless. Trying to execute

 let f = \y. (let f : a -> a = y in f 3) in f (\x.\y. x y) + 1

(in creative mode so arithmetic is allowed) results in a fatal error:

 fatal error: Bad application of execConst:
  ◀ let x = 3 in \y. x y + 1
  []

I will follow up with a fix shortly, but wanted to officially record the bug for completeness.

@byorgey byorgey added Bug The observed behaviour is incorrect or unexpected. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. L-Type inference The process of inferring the type of a Swarm expression. labels Oct 11, 2021
@byorgey
Copy link
Member Author

byorgey commented Oct 11, 2021

let f = \y. (let f : a -> a = y in f 3) in f (\x.\y. x y) + 1 now results in an error (as it should): Skolem variable s2 would escape its scope. It's not a great error message, but also not one that anyone is very likely to encounter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug The observed behaviour is incorrect or unexpected. L-Type inference The process of inferring the type of a Swarm expression. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact.
Projects
None yet
Development

No branches or pull requests

1 participant