Skip to content

Builder? causes invalid FunC code — store_slice used instead of proper serialization #2999

@Gusarich

Description

@Gusarich

Using an optional Builder compiles in Tact but crashes during FunC compilation. The docs say all primitive types, including Builder, can be nullable — but the compiler generates invalid code when serializing Builder?.


Example:

contract Test {
    builderOpt: Builder?;

    init() {
        self.builderOpt = null;
    }

    receive() {
        self.builderOpt = null;
    }
}

Expected:
Compiles fine. Docs say:

"All primitive types, as well as Structs and Messages, can be nullable..."


Actual:
FunC crash:

FunC compilation error: ...: error: cannot apply function store_slice : (builder, slice) -> builder to arguments of type (builder, builder): cannot unify type builder with slice
      build_0 = build_0.store_maybe_ref(begin_cell().store_slice(v'builderOpt).end_cell());

Compiler tries to store_slice a Builder, which makes no sense.


Conclusion:
Type system allows Builder?, but codegen doesn't handle it — using store_slice for a builder.


LLM Fuzzing discovery (see #2490)

Metadata

Metadata

Assignees

Labels

activity: llm-fuzzingIssues found using LLM fuzzingkind: bugSomething isn't working or isn't rightscope: codegenCode generation, a.k.a. compiler backend (src/generator)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions