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: After internalization, lambda return is wrong #1855

Closed
poeface opened this issue Jan 21, 2023 · 2 comments
Closed

Comments

@poeface
Copy link

poeface commented Jan 21, 2023

In the process of developing a solver I found this new error:

Internal compiler error.  Please report this:
  https://github.com/diku-dk/futhark/issues
After internalisation:
In function lifted_lambda_6629
When checking the body aliases: [[mode_7261, mode_7262], [mode_7261, mode_7262]]
A unique tuple element of return value of function lifted_lambda_6629 is aliased to some other tuple component.

my futhark version is hot off the press:

Futhark 0.23.0 (prerelease - include info below when reporting bugs)
git: cb9d1c1 (Sat Jan 21 16:40:39 2023 +0100)

Here is code that generates the bug: internalization_bug.zip

The bug arises from somewhere in the block from line 42 to 47.

Hope that helps!

@athas
Copy link
Member

athas commented Jan 21, 2023

Smaller case:

type t [n] = #foo [n](i32,i32) | #bar

def main (x: t []) =
  (\x -> match x
         case #foo arr -> take 2 arr
         case _ -> [(0,1)]) x

Looks like lambda lifting is inferring the wrong uniqueness of a return type. Should not be too difficult to fix. Futhark 0.21.1 also has this bug, so it is not new.

@athas
Copy link
Member

athas commented Jan 21, 2023

Actually, this is a problem in type checking, where we don't propagate aliases when we pattern match on an incompletely known sum type.

In the long run I think we should move all alias/consumption checking to a second type checking phase, where we know completely the type structure, but I think I can patch this for now.

@athas athas closed this as completed in 3f2a2ef Jan 21, 2023
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