Skip to content

Inline procs with Any parameters produce wrong output #9

@ehartford

Description

@ehartford

Bug

When a procedure is marked inline and takes an Any parameter, calls produce completely wrong output. Without inline, the same procedure works correctly.

Reproduction

// examples/17/17.10_inline.jai
println :: inline (arg: Any) { print("%\n", arg); }

n := 14;
m := 36;
println("Hello, world!");  // should print "Hello, world!"
println(1);                // should print "1"
println("% %", n, m);     // should print "14 36"
println("The end.");       // should print "The end."

Expected: Four lines of output
Actual: Only outputs 1 total

Removing the inline keyword makes all four calls work correctly. This confirms the bug is specifically in the inline + Any parameter interaction.

Root Cause Analysis

The tryInlineProcCall path in bytecode_gen.zig likely doesn't properly handle the Any type boxing that happens when an argument is passed to an Any-typed parameter. The normal call path boxes the argument correctly; the inline expansion skips the boxing or mishandles the type coercion.

Severity

Highinline is a common Jai idiom, and Any parameters are used for variadic printing. This combination completely breaks output.

Files

  • bootstrap/src/bytecode_gen.zig (tryInlineProcCall, inline parameter handling)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions