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

Internal Compiler Error Example #1 #1751

Closed
tharnival opened this issue Nov 3, 2022 · 1 comment
Closed

Internal Compiler Error Example #1 #1751

tharnival opened this issue Nov 3, 2022 · 1 comment

Comments

@tharnival
Copy link

tharnival commented Nov 3, 2022

With the files 1.fut (renamed because GitHub doesn't accept .fut):
1.txt
(At line 43 and 47 are some comments about the general location of the problem.)

And games.fut (again renamed):
games.txt

If I run the command "futhark opencl 1.fut" with Futhark 0.22.0, I get the error:

Internal compiler error.  Please report this:
  https://github.com/diku-dk/futhark/issues
After internalisation:
In function brute_force_8110
When checking function body
In expression of statement
  {brute_force_res_12160 : ({}, [1i64]f64),
   brute_force_res_12161 : ({}, i64)}
in true branch
In expression of statement
  {results_12239 : ({}, i64),
   results_12240 : ({}, i64),
   results_12241 : ({}, bool),
   results_12242 : ({}, [1i64][n₆_12163]i32),
   results_12243 : ({}, [1i64][n₆_12163]i32),
   results_12244 : ({}, [1i64][depth2_12148]i64),
   results_12245 : ({}, [1i64]i64),
   results_12246 : ({}, [1i64]bool),
   results_12247 : ({}, [1i64][n₆_12163]f64),
   results_12248 : ({}, [1i64][n₆_12163]f64),
   results_12249 : ({}, [1i64][n₆_12163]f64),
   results_12250 : ({}, [1i64]i64),
   results_12251 : ({states_12183, states_12184, states_12185, states_12186,
                     states_12187, states_12188, states_12189, states_12190,
                     states_12191, loop_init_12192}, [results_12239]i64),
   results_12252 : ({loop_init_12193}, [results_12240]i64)}
Type error:
Variable states_12174 referenced after being consumed.
@athas
Copy link
Member

athas commented Nov 3, 2022

I think this program is wrong and shouldn't pass the type checker. Here is a simpler example of what is happening:

def main [n] (xs: *[n](i32,i32)) =
  let f i = let (a,_) = xs[i] in a
  in loop xs for i < n do xs with [i] = (f i, f i)

A local function is closing over a variable that is consumed later, yet we can still apply that function. We do track aliases of functions for just this reason, but there must be a bug somewhere.

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

2 participants