Stream: compiler development

Topic: error in alias analysis


view this post on Zulip Luke Boswell (Aug 31 2024 at 02:18):

I found the thing causing the error in alias analysis in my JWT PR. Calling Task.mapErr twice seems to be the issue.

ok

verify = \{algorithm, secret, token} ->
    PlatformTasks.jwtVerify {algo: algoToU8 algorithm, secret, token}
    |> Task.mapErr \err -> JwtErr (mapErrFromHost err)

error in alias analysis

verify = \{algorithm, secret, token} ->
    PlatformTasks.jwtVerify {algo: algoToU8 algorithm, secret, token}
    |> Task.mapErr mapErrFromHost
    |> Task.mapErr JwtErr

view this post on Zulip Sam Mohr (Aug 31 2024 at 02:18):

...huh

view this post on Zulip Luke Boswell (Aug 31 2024 at 02:19):

thread 'main' panicked at crates/compiler/gen_llvm/src/llvm/build.rs:5770:19:
Error in alias analysis: error in module ModName("UserApp"), function definition FuncName("%\x00\x00\x00\x0c\x00\x00\x00w\x08\xf21\x00na\xb2"):
expected type '
union { ((heap_cell,), ()), (union { (), (), (), (), (), (), (), (), ((heap_cell,),) },), ((heap_cell,),) }',
found type '
union { (), (), (), (), (), (), (), (), ((heap_cell,),) }'

view this post on Zulip Luke Boswell (Aug 31 2024 at 02:19):

I mean this stuff is black magic to me... but I thought it may be a clue that helps.

view this post on Zulip Luke Boswell (Aug 31 2024 at 02:20):

I'm just stoked because I think I can finish cleaning this up and land it!

view this post on Zulip Sam Mohr (Aug 31 2024 at 02:20):

Very much a guess, but it seems related to the wrapping and unwrapping of lambdas, which I guess is unsurprising: https://github.com/roc-lang/roc/blob/f6c969af293270feb90dfdc8fcc3ffbe18f9b268/crates/compiler/builtins/roc/Task.roc#L179

view this post on Zulip Sam Mohr (Aug 31 2024 at 02:20):

That's the impl of mapErr

view this post on Zulip Sam Mohr (Aug 31 2024 at 02:21):

The same kind of code is usually to blame, in my experience

view this post on Zulip Luke Boswell (Aug 31 2024 at 02:33):

Found another example...

works

    # Test HS383 algorithm
    {
        secret: "shhh_very_secret",
        algorithm: Hs384,
        token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.joReqPNNkWQ8zQCW3UQnhc_5NMrSZEOQYpk6sDS6Y-o",
    }
        |> Jwt.verify
        |> Task.await assertClaims
        |> Task.mapErr! \err -> Hs384TestErr err

error in alias analysis

# Test HS383 algorithm
    {
        secret: "shhh_very_secret",
        algorithm: Hs384,
        token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.joReqPNNkWQ8zQCW3UQnhc_5NMrSZEOQYpk6sDS6Y-o",
    }
        |> Jwt.verify
        |> Task.await assertClaims
        |> Task.mapErr! Hs384TestErr
Error in alias analysis: error in module ModName("UserApp"), function definition FuncName("\x11\x00\x00\x00\"\x00\x00\x00\xc53#(\xb1\xc0\xf1\x04"):
expected type
'union { ((heap_cell,), ()), (union { (), (union { (), (), (), (), (), (), (), (), ((heap_cell,),) },), () },), (union { (), (union { (), (), (), (), (), (), (), (), ((heap_cell,),) },), () },), ((heap_cell,),) }',
found type
'union { (union { (), (union { (), (), (), (), (), (), (), (), ((heap_cell,),) },), () },), (union { (), (union { (), (), (), (), (), (), (), (), ((heap_cell,),) },), () },), ((heap_cell,),) }'

view this post on Zulip Brendan Hansknecht (Aug 31 2024 at 07:46):

I wonder if any of these work arounds could fix the sqlite pr

view this post on Zulip Luke Boswell (Aug 31 2024 at 07:47):

I had the same thought. I was going to have a look tomorrow :grinning:


Last updated: Jul 06 2025 at 12:14 UTC