Skip to content

fix(errors): position-aware error for print(record) / unsupported print type#127

Merged
MelbourneDeveloper merged 3 commits into
mainfrom
fix/print-record-error-position
May 26, 2026
Merged

fix(errors): position-aware error for print(record) / unsupported print type#127
MelbourneDeveloper merged 3 commits into
mainfrom
fix/print-record-error-position

Conversation

@MelbourneDeveloper
Copy link
Copy Markdown
Owner

Summary

  • `print(p)` on a record value previously failed with a bare `cannot convert value for printing` — no line/column, no hint about which type.
  • `convertPrimitiveToString` / `convertResultValueToString` now thread the print call's source position and the inferred type name through to a new `WrapPrintCannotConvertWithPos`, so the error pins the offending call and names the type.
  • `typeNameForError` prefers the inferred-type name and falls back to the LLVM type when the inferer left an unresolved variable (`t12`).
  • String-interpolation site (`${p}`) gets the same wrapping via `interpStr.Position`.

Before: `Execution failed: failed to generate LLVM IR: cannot convert value for printing`
After: `Execution failed: failed to generate LLVM IR: line 10:4: cannot convert value for printing: {x: int, y: int}`

Test plan

  • New failscompilation fixture `print_record_unsupported.ospo` pins the line/column + type-name in the expected output.
  • CI green.

🤖 Generated with Claude Code

MelbourneDeveloper and others added 2 commits May 26, 2026 18:52
…nt type

print(p) on a record value used to fail with a bare 'cannot convert
value for printing' — no line/column, no hint about which type.
convertPrimitiveToString / convertResultValueToString now thread the
print call's source position and the inferred type name through to a
new WrapPrintCannotConvertWithPos so the error pins the offending
call and names the type.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@MelbourneDeveloper MelbourneDeveloper enabled auto-merge (squash) May 26, 2026 08:53
RecordType.String() iterated a Go map, so error messages containing a
record type rendered with non-deterministic field order. Locally tests
saw `{x: int, y: int}` but CI saw `{y: int, x: int}` and the
.expectedoutput fixture failed.

Sorting field names alphabetically gives a stable rendering that's
the same on every run and platform.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@MelbourneDeveloper MelbourneDeveloper merged commit e96676d into main May 26, 2026
1 of 2 checks passed
@MelbourneDeveloper MelbourneDeveloper deleted the fix/print-record-error-position branch May 26, 2026 09:08
MelbourneDeveloper added a commit that referenced this pull request May 29, 2026
…nt type (#127)

## Summary
- \`print(p)\` on a record value previously failed with a bare \`cannot
convert value for printing\` — no line/column, no hint about which type.
- \`convertPrimitiveToString\` / \`convertResultValueToString\` now
thread the print call's source position and the inferred type name
through to a new \`WrapPrintCannotConvertWithPos\`, so the error pins
the offending call and names the type.
- \`typeNameForError\` prefers the inferred-type name and falls back to
the LLVM type when the inferer left an unresolved variable (\`t12\`).
- String-interpolation site (\`\${p}\`) gets the same wrapping via
\`interpStr.Position\`.

Before: \`Execution failed: failed to generate LLVM IR: cannot convert
value for printing\`
After: \`Execution failed: failed to generate LLVM IR: line 10:4: cannot
convert value for printing: {x: int, y: int}\`

## Test plan
- [x] New failscompilation fixture \`print_record_unsupported.ospo\`
pins the line/column + type-name in the expected output.
- [ ] CI green.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
MelbourneDeveloper added a commit that referenced this pull request May 29, 2026
…nt type (#127)

## Summary
- \`print(p)\` on a record value previously failed with a bare \`cannot
convert value for printing\` — no line/column, no hint about which type.
- \`convertPrimitiveToString\` / \`convertResultValueToString\` now
thread the print call's source position and the inferred type name
through to a new \`WrapPrintCannotConvertWithPos\`, so the error pins
the offending call and names the type.
- \`typeNameForError\` prefers the inferred-type name and falls back to
the LLVM type when the inferer left an unresolved variable (\`t12\`).
- String-interpolation site (\`\${p}\`) gets the same wrapping via
\`interpStr.Position\`.

Before: \`Execution failed: failed to generate LLVM IR: cannot convert
value for printing\`
After: \`Execution failed: failed to generate LLVM IR: line 10:4: cannot
convert value for printing: {x: int, y: int}\`

## Test plan
- [x] New failscompilation fixture \`print_record_unsupported.ospo\`
pins the line/column + type-name in the expected output.
- [ ] CI green.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------
MelbourneDeveloper added a commit that referenced this pull request May 29, 2026
…nt type (#127)

## Summary
- \`print(p)\` on a record value previously failed with a bare \`cannot
convert value for printing\` — no line/column, no hint about which type.
- \`convertPrimitiveToString\` / \`convertResultValueToString\` now
thread the print call's source position and the inferred type name
through to a new \`WrapPrintCannotConvertWithPos\`, so the error pins
the offending call and names the type.
- \`typeNameForError\` prefers the inferred-type name and falls back to
the LLVM type when the inferer left an unresolved variable (\`t12\`).
- String-interpolation site (\`\${p}\`) gets the same wrapping via
\`interpStr.Position\`.

Before: \`Execution failed: failed to generate LLVM IR: cannot convert
value for printing\`
After: \`Execution failed: failed to generate LLVM IR: line 10:4: cannot
convert value for printing: {x: int, y: int}\`

## Test plan
- [x] New failscompilation fixture \`print_record_unsupported.ospo\`
pins the line/column + type-name in the expected output.
- [ ] CI green.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant