Skip to content

fix(builtins): awk array assignment fails with field refs and compound subscripts #396

@chaliy

Description

@chaliy

Bug

Multiple awk array features are broken, surfaced by eval tasks config_ini_merge, db_csv_join_aggregate, build_script_generator, and config_env_template. All 5 eval models hit these bugs.

1. Array assignment with field references as indices

category[$1] = $3 fails with awk: invalid assignment target. The parser at awk.rs:1020-1082 doesn't recognize FuncCall("__array_access", ...) when field references ($N) are used as subscripts.

echo "a b c" | awk '{ arr[$1] = $3; print arr["a"] }'
# Expected: c
# Actual: awk: invalid assignment target

2. Multi-subscript arr[e1, e2] syntax unsupported

POSIX awk a["x","y"] (comma-separated subscripts, concatenated with SUBSEP) fails with expected ']'. The parser at awk.rs:1562 calls parse_expression() which doesn't handle commas as SUBSEP separators inside [].

echo "test" | awk 'BEGIN { a["x","y"] = 1; print a["x","y"] }'
# Expected: 1
# Actual: awk: expected ']'

3. SUBSEP variable undefined

The POSIX awk SUBSEP variable (default \034) is never initialized. Grep for "SUBSEP" in awk.rs returns zero matches.

4. Pre-increment of array element ++arr[key] unsupported

++arr[key] fails because the PreIncrement handler at awk.rs:1353 only accepts AwkExpr::Variable(name), but arr[key] parses as FuncCall("__array_access", ...).

echo "a\nb\na" | awk '{ ++count[$1] } END { for (k in count) print k, count[k] }'
# Expected: a 2\nb 1
# Actual: error

Impact

These bugs make any multi-file awk processing with associative arrays impossible. Eval tasks requiring CSV joins, INI merging, or dependency graph processing all fail across all 5 models.

Eval Tasks Affected

  • config_ini_merge (all 5 models FAIL)
  • db_csv_join_aggregate (Haiku, Opus FAIL)
  • build_script_generator (4/5 FAIL)
  • config_env_template (GPT-5.2, GPT-5.3-Codex FAIL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions