Stream: bugs

Topic: ✔ Json.parse panic: checked generated codec contract had ...


view this post on Zulip Scott Campbell (Sep 14 2026 at 04:15):

Marking as done in zulip.
Moved to github: [Open] https://github.com/roc-lang/roc/issues/11384

thread 154648 panic: postcheck invariant violated: checked generated codec contract had overlapping direct call roles

Version:
app [main!] { roc: "nightly-2026-09-11-793f9d8", pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/1.0.0/AnZoxzoGPtSGQ15EQh6pBeeaHJ7aizP9MQhK81dES3Uq.tar.zst" }

App Source:
https://github.com/scottc/godot-roc/blob/c910a29e8eab57daeacab33e8f63ec52eafe8066/scripts/godot-api-client-generator/main.roc

Type Def:
https://github.com/scottc/godot-roc/blob/c910a29e8eab57daeacab33e8f63ec52eafe8066/scripts/godot-api-client-generator/Godot.roc

350,000 line json file:
https://github.com/scottc/godot-roc/blob/c910a29e8eab57daeacab33e8f63ec52eafe8066/scripts/godot-api-client-generator/extension_api.json

Running the code:

cd scripts/godot-api-client-generator

cat extension_api.json | roc main.roc > generated_code.roc

It works for a simple Json object, but once I've added a few large fields... I encounter this error.

Output:

thread 154648 panic: postcheck invariant violated: checked generated codec contract had overlapping direct call roles
???:?:?: 0x7c24458 in common.invariant__anon_561977 (???)
???:?:?: 0x7c23b36 in monotype.lower.BodyContext.generatedCodecCall (???)
???:?:?: 0x7c1e366 in monotype.lower.BodyContext.requiredGeneratedCodecTarget (???)
???:?:?: 0x7c4288a in monotype.lower.BodyContext.prepareParseFormatControlCodecCall (???)
???:?:?: 0x7c408a9 in monotype.lower.BodyContext.prepareParseListFormatCodecCalls (???)
???:?:?: 0x7c07686 in monotype.lower.BodyContext.prepareCustomCodecCallsAtNode (???)
???:?:?: 0x7c08d15 in monotype.lower.BodyContext.prepareCustomCodecCallsAtNode (???)
???:?:?: 0x7c0783f in monotype.lower.BodyContext.prepareCustomCodecCallsAtNode (???)
???:?:?: 0x7c08d15 in monotype.lower.BodyContext.prepareCustomCodecCallsAtNode (???)
???:?:?: 0x7c0783f in monotype.lower.BodyContext.prepareCustomCodecCallsAtNode (???)
???:?:?: 0x7c08d15 in monotype.lower.BodyContext.prepareCustomCodecCallsAtNode (???)
???:?:?: 0x7e4284d in monotype.lower.BodyContext.deferStructuralSerializationAtNode (???)
???:?:?: 0x7e3aa30 in monotype.lower.BodyContext.lowerDispatchExprAtType (???)
???:?:?: 0x786aecd in monotype.lower.BodyContext.lowerExprAtTypeCellInner (???)
???:?:?: 0x78671db in monotype.lower.BodyContext.lowerExprAtTypeCellWithKnownDivergence (???)
???:?:?: 0x7da7168 in monotype.lower.BodyContext.lowerPatternStatement (???)
???:?:?: 0x7d719b5 in monotype.lower.BodyContext.lowerStatement (???)
???:?:?: 0x7d6f9aa in monotype.lower.BodyContext.lowerBlockStatements (???)
???:?:?: 0x7e3532f in monotype.lower.BodyContext.lowerBlockAtTypeCell__anon_535337 (???)
???:?:?: 0x786b54a in monotype.lower.BodyContext.lowerExprAtTypeCellInner (???)
???:?:?: 0x78671db in monotype.lower.BodyContext.lowerExprAtTypeCellWithKnownDivergence (???)
???:?:?: 0x786661c in monotype.lower.BodyContext.lowerExprAtTypeCellWithDemand (???)
???:?:?: 0x78664d1 in monotype.lower.BodyContext.lowerExprAtTypeCell (???)
???:?:?: 0x7ed16b9 in monotype.lower.BodyContext.lowerLambdaArgsAndBodyAtCell (???)
???:?:?: 0x7ecc243 in monotype.lower.BodyContext.lowerLambdaTemplateAtNode__anon_521144 (???)
???:?:?: 0x766eeb7 in monotype.lower.BodyContext.lowerTemplateBodyAtNode (???)
???:?:?: 0x75b8a1b in monotype.lower.Builder.lowerReservedTemplateBodyIntoDraft (???)
???:?:?: 0x809e06b in monotype.lower.Builder.lowerPendingSpecJobToShard (???)
???:?:?: 0x809c1a0 in monotype.lower.Builder.runSpecJobTask (???)
???:?:?: 0xa2b2549 in coordinator.Coordinator.workerThread (???)
???:?:?: 0xa2b1d93 in Thread.callFn__anon_833722 (???)
???:?:?: 0xa2b180d in Thread.PosixThreadImpl.spawn__anon_833703.Instance.entryFn (???)
???:?:?: 0x7ffff7c9ce72 in start_thread (/nix/store/lm3pknxi0ipypy3lxh1wmm8wvvavdwrn-glibc-2.42-84/lib/libc.so.6)
???:?:?: 0x7ffff7d242bb in __clone3 (/nix/store/lm3pknxi0ipypy3lxh1wmm8wvvavdwrn-glibc-2.42-84/lib/libc.so.6)

See Godot.roc type def comments for which fields cause panic:

ExtensionApi : {
    # commented out so we can test 1-by-1 in isolation.

    #header : Header, # working
    #builtin_class_sizes : List(BuiltinClassSizes), # working
    #builtin_class_member_offsets : List(BuiltinClassMemberOffsets), # working
    #global_constants : List(GlobalConstant),   # often empty [] # working

    # working, in isolation, panic when combined with fields above & below, Json is too large...?
    #  thread 154648 panic: postcheck invariant violated: checked generated codec contract had overlapping direct call roles
    #global_enums : List(EnumDef),

    # TODO: FIX Types, with optional fields? v

    #utility_functions : List(UtilityFunction), #Err(MissingRequiredField("arguments"))
    #builtin_classes : List(BuiltinClass), #Err(MissingRequiredField("right_type"))

    # TODO: FIX Types, with optional fields? ^

    # thread 154648 panic: postcheck invariant violated: checked generated codec contract had overlapping direct call roles
    #classes : List(ClassDef),


    #singletons : List(Singleton), # working
    #native_structures : List(NativeStructure), # working
}

There is also a flake.nix in the root directory, for reproduceable dev env:

nix develop

cd scripts/godot-api-client-generator

cat extension_api.json | roc main.roc > generated_code.roc

And I can pin an exact git hash in the url specifier if needed.
roc.url = "github:roc-lang/roc?dir=src";

view this post on Zulip Luke Boswell (Sep 14 2026 at 04:36):

@Scott Campbell is there something you wanted to discuss about this?

view this post on Zulip Luke Boswell (Sep 14 2026 at 04:37):

You could make a GH Issue with this if you like, it's definitely a bug :ladybug:

view this post on Zulip Scott Campbell (Sep 14 2026 at 04:41):

Ok, will do... Created: https://github.com/roc-lang/roc/issues/11384

I'll create github issues from now on.

Thanks!

view this post on Zulip Notification Bot (Sep 14 2026 at 04:45):

Scott Campbell has marked this topic as resolved.


Last updated: Sep 24 2026 at 15:59 UTC