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: Case branch with a "let...in..." inside returns a different type? #1847

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

Comments

@poeface
Copy link

poeface commented Jan 18, 2023

Hey I'm back with another match-statement related bug. I don't think this is the same as my last issue since the pass name (internalisation) and cause appear to be different.

Like before, I trimmed the code down as much as possible. Lines 17-18 contain the offending code. If those lines are replaced with line 20, the error disappears. Something to do with having a let __ in __ in the body of a case ___ -> ___.

This problem happened when compiling for both C and multicore targets.

bug.zip

Finally, here is a printout of compiler's output:

Internal compiler error.  Please report this:
  https://github.com/diku-dk/futhark/issues
After internalisation:
In function makeConvLayer_6036
When checking function body
In expression of statement
  {makeConvLayer_res_6528 : ({}, i64),
   makeConvLayer_res_6529 : ({}, i64),
   makeConvLayer_res_6530 : ({}, i8),
   makeConvLayer_res_6531 : ({}, [makeConvLayer_res_6528][makeConvLayer_res_6529]f64)}
in body of case {1i8}
Type error:
Type annotation is
  {i64, i64, i8, [?0][?1]f64}
But result returns type
  {i64, i64, i8, [NM_6521][NM_6521]f64, [defunc_2_tabulate_2d_arg_6536][defunc_2_tabulate_2d_arg_6535]f64}

Hope that's enough info!

athas added a commit that referenced this issue Jan 18, 2023
@athas athas closed this as completed in 5cdb905 Jan 18, 2023
@athas
Copy link
Member

athas commented Jan 18, 2023

This bug was due to two factors we hadn't seen combined before:

  1. Using complex initialisation expressions in sum types.
  2. Using a sum type that contains arrays.

The first is just a matter of style preference, but the second is often not a good idea. However, it is fine in this case because the arrays along the different constructors have the same type, and it should definitely work. And now it does. (Hopefully. I still suspect there are bugs lurking in defunctionalisation where we don't propagate sizes properly. Fortunately they almost always result in compiler crashes rather than silent miscompilation.)

@poeface
Copy link
Author

poeface commented Jan 18, 2023

Thanks for the pointer about array types in sum types--this is definitely something I wouldn't have thought to be an issue but is quite valuable to know about!

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