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

Strange SplitTypes coercion #559

Closed
hummy123 opened this issue May 5, 2024 · 1 comment
Closed

Strange SplitTypes coercion #559

hummy123 opened this issue May 5, 2024 · 1 comment

Comments

@hummy123
Copy link

hummy123 commented May 5, 2024

Hi there. I was trying to implement a B-Tree at this repository but the insMany function in the .sml file caused a compilation error with MLton:

MLton 20210117 raised: Fail: SplitTypes.TypeInfo.coerce: Strange coercion: () coerced to word32 in val x_0: (word32) vector = prim Vector_vector[word32] (unit_0) in L_0 in insMany_0

This error occurred on two machines: a Raspberry Pi 5 and a Mac M2 (with the latest commit tested on the Raspberry Pi, and the 2021 version from the error message tested on the Mac).

I don't have an X86 machine with me to test if this is exclusively an error with MLton's ARM output unfortunately.

The error isn't raised when the insMany function is removed from the sole .sml file in the repository so I tried replacing it with a mutable while loop, but the while-loop version caused the error to be raised again.

@MatthewFluet
Copy link
Member

Confirmed, with both MLton 20210117 and current sources.

The bug is actually with the useless pass, just that the miscompilation doesn't trigger another ICE until the splitTypes2 pass. This can be observed by compiling with -type-check true, which runs the SSA type checker after every optimization pass, often discovering miscompilations that manifest as ill-typed IR programs:

         useless starting
            save bench.useless.pre.ssa starting
            save bench.useless.pre.ssa finished in 0.01 + 0.00 (0% GC)
            save bench.useless.post.ssa starting
            save bench.useless.post.ssa finished in 0.00 + 0.00 (0% GC)
            useless:typeCheck starting
               useless:typeCheck raised: Fail: TypeError (SSA): Ssa.TypeCheck.primApp (Vector_vector(word32) (unit)) in val x_509: (word32) vector = prim Vector_vector[word32] (unit_0) in L_318 in insMany_0
            useless:typeCheck raised in 0.00 + 0.00 (0% GC)
         useless raised in 0.02 + 0.00 (0% GC)

Seems to be related to the use of a singleton vector expression, which becomes the Vector_vector primitive.

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

No branches or pull requests

2 participants