← board

bug: ArgStr(i, s) into a managed-string var rejected/broken on cross targets

Symptom

./compiler/pascal26 --target=i386 test/test_arm32_arg_runtime.pas /tmp/x
pascal26:13: error: target i386: ArgStr expects a string variable ()

Line 13 is ArgStr(2, fixed) where fixed: string. Same on aarch64 / arm32.

Root cause

Scalar string is managed (tyAnsiString) by default now (pinned v26). So the ArgStr destination lowers to IR_LOAD_SYM over a managed-handle slot.

So today the cross backends hit IRKind[valNode] <> IR_LEA → the loud parse-time error above. (Naively also accepting IR_LOAD_SYM is NOT a fix — it then runs the fixed-string emitter against a managed slot and segfaults at the first read of the string: verified qemu: uncaught target signal 11.)

Fix

Give i386 / arm32 / aarch64 a managed-string ArgStr path mirroring x86-64's EmitArgvToStringManaged: accept the IR_LOAD_SYM dest, and when Syms[symIdx].TypeKind = tyAnsiString build a heap AnsiString from argv[index] (length scan + alloc + copy + store handle) instead of the inline fixed buffer. Each backend already has managed-string heap-assign helpers to build on.

Acceptance

make test-i386, make test-aarch64, make test-arm32 green; the three cross runs of test_arm32_arg_runtime match the x86-64 oracle (3 / <arg1> / <arg2>).

Not this

Fix log