fix(errors): position-aware error for print(record) / unsupported print type#127
Merged
Merged
Conversation
…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>
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
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) ---------
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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
🤖 Generated with Claude Code