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

eval_Var_bug #43

Merged
merged 1 commit into from
Dec 3, 2024
Merged

Conversation

oshimayuki1124
Copy link
Contributor

When you run the code below,
let f = fun x -> ((fun y -> y):?->?) x in let g = f in g (g 2 = 3);;
you will get an error message: Fatal error: exception Lambda_dti.Eval.Eval_bug("cannot cast value: 2").

I got the sentences below by debug-mode.

...
***** Cast-insertion *****
f: let f = fun 'x11,'x10 -> fun (x: 'x11) -> ((fun (y: 'x10) -> y): 'x10 -> 'x10 => ? -> ?) (x: 'x11 => ?) in (let g = fun 'x12 -> f['x12,ν] in g[bool] ((g[int] 2: ? => int) = 3))
U: ?
***** Eval *****
eval <-- let f = fun 'x11,'x10 -> fun (x: 'x11) -> ((fun (y: 'x10) -> y): 'x10 -> 'x10 => ? -> ?) (x: 'x11 => ?) in (let g = fun 'x12 -> f['x12,ν] in g[bool] ((g[int] 2: ? => int) = 3))
eval <-- fun (x: 'x11) -> ((fun (y: 'x10) -> y): 'x10 -> 'x10 => ? -> ?) (x: 'x11 => ?)
eval <-- let g = fun 'x12 -> f['x12,ν] in g[bool] ((g[int] 2: ? => int) = 3)
eval <-- f['x12,ν]
eval <-- g[bool] ((g[int] 2: ? => int) = 3)
eval <-- g[bool]
eval <-- (g[int] 2: ? => int) = 3
eval <-- g[int] 2: ? => int
eval <-- g[int] 2
eval <-- g[int]
eval <-- 2
eval <-- ((fun (y: 'x15) -> y): 'x15 -> 'x15 => ? -> ?) (x: 'x12 => ?)
eval <-- (fun (y: 'x15) -> y): 'x15 -> 'x15 => ? -> ?
eval <-- fun (y: 'x15) -> y
cast <-- : 'x15 -> 'x15 => ? -> ?
eval <-- x: 'x12 => ?
eval <-- x
cast <-- 2: 'x12 => ?
Fatal error: exception Lambda_dti.Eval.Eval_bug("cannot cast value: 2")

This shows that 'x12 is not substituted to int. This causes from eval in eval.ml which substitute types into type variables only once when evaluating Var.
To fix it, I let eval catch the set of type variables and types, and then give proc to substituted type.

However, this code only evaluates to blame after this modification, because ν is changed to fresh type variable in evaluating ... let g = f in ..., and this fresh type variable is no more freshed in evaluating g (g 2 =3).
This can be improved by correction in type inference process, but I didn't change it.

@ymyzk
Copy link
Owner

ymyzk commented Dec 3, 2024

Thanks again for the contribution!

However, this code only evaluates to blame after this modification, because ν is changed to fresh type variable in evaluating ... let g = f in ..., and this fresh type variable is no more freshed in evaluating g (g 2 =3).
This can be improved by correction in type inference process, but I didn't change it.

I understand the limitation with the approach. As this project is not under active development and I have limited bandwidth for maintenance, I'll likely keep this it as is for the time being.

@ymyzk ymyzk merged commit 5c69555 into ymyzk:master Dec 3, 2024
43 checks passed
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