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

Infinite loop in type checker #2073

Closed
athas opened this issue Jan 7, 2024 · 1 comment
Closed

Infinite loop in type checker #2073

athas opened this issue Jan 7, 2024 · 1 comment
Assignees

Comments

@athas
Copy link
Member

athas commented Jan 7, 2024

def f [n] (dmax: i64) (depth: [n]i64) (value: [n]i32) (parent: [n]i64) : []i32 =
  loop value for d in dmax..dmax-1...1 do
    reduce_by_index
    (copy value)
    (+)
    0i32
    (map (\i -> if depth[i] == d then parent[i] else -1) (iota (length value)))
    value

Probably in loop size analysis, which runs a convergence loop. This program is not well typed, so we should definitely report a type error.

@athas athas self-assigned this Jan 7, 2024
@athas
Copy link
Member Author

athas commented Jan 8, 2024

This program has the same problem, although for arbitrary reasons the type checker doesn't go into an infinite loop, but does complain about it in a late sanity check:

entry main (xs: []i32) = zip (iota (length xs)) xs

The problem is that xs gets inferred as having type [length xs]i32. Similarly, in the first program above, the loop parameter value is inferred as having size length value. That's of course not sensible.

@athas athas closed this as completed in 63b36ac Jan 8, 2024
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