Problem
Found while working on #80 (see also PR #527): print numerically coerces string literals that look like numbers, losing their original text:
$ jawk 'BEGIN { print "0100"; print "1e3"; print "+0100"; print "-0500" }'
100
1000
100
-500
gawk (and POSIX AWK) print them verbatim:
$ gawk 'BEGIN { print "0100"; print "1e3"; print "+0100"; print "-0500" }'
0100
1e3
+0100
-0500
Per POSIX, a string constant is a string, never a strnum, so print must output it unchanged. Only the numeric-string (strnum) semantics of input-sourced values allow numeric interpretation — and even then, printing uses the original string form.
Notes
- Only bare prints appear to be affected; concatenation is fine:
print "[" "0100" "]" correctly outputs [0100].
- This suggests the print statement (or the evaluation of a lone string-constant expression) applies a strnum/number conversion somewhere in the AVM print handling or in the string-literal push opcode.
- Beware of test fallout when fixing: other tests may unknowingly rely on the buggy collapse.
🤖 Generated with Claude Code
Problem
Found while working on #80 (see also PR #527):
printnumerically coerces string literals that look like numbers, losing their original text:gawk (and POSIX AWK) print them verbatim:
Per POSIX, a string constant is a string, never a strnum, so
printmust output it unchanged. Only the numeric-string (strnum) semantics of input-sourced values allow numeric interpretation — and even then, printing uses the original string form.Notes
print "[" "0100" "]"correctly outputs[0100].🤖 Generated with Claude Code