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

Inconsistency in sizes going out of scope #2193

Closed
athas opened this issue Nov 19, 2024 · 0 comments
Closed

Inconsistency in sizes going out of scope #2193

athas opened this issue Nov 19, 2024 · 0 comments

Comments

@athas
Copy link
Member

athas commented Nov 19, 2024

This does not work:

def takefrom 't (xs: []t) (i: i64) : [i+1]t = take (i+1) xs

entry main n (xs: []i32) =
  n |> takefrom xs
Cannot apply "|>" to "takefrom xs" (invalid type).
Expected: a₂ -> b₃
Actual:   (i: i64) -> [i + 1]i32

Parameter(s) "i" used as size(s) would go out of scope.

But it works if we use this definition of takefrom:

def takefrom 't (xs: []t) (i: i64) : [i]t = take i xs

In this case the size that goes out of scope is just turned into an existential. I suspect the code that detects this case does not handle nontrivial expressions properly. I see no reason not to always decay to an existential in such cases.

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

No branches or pull requests

1 participant