compiler: keep the C++ throw site out of user diagnostics (#557) - #573
Merged
Merged
Conversation
orlyc printed
2:28-2:47 [orly/type/add_visitor.h, 50]This expression is invalid.
for a newcomer's `<['counter']> += n`. That is a path into the compiler's
own source, glued to the message with no space, and it reads like a crash.
TSourceError now keeps the TCodeLocation as a field instead of splicing it
into what(). orlyc shows it under --compiler-locations; WS source_error
replies carry it as a separate compiler_loc key. TImpossibleError keeps it
in the message, since for an internal compiler error the location is the
report.
TMutate::TypeCheck now requires the target to be a stored value. A bare
address used to fall through to the operator visitor's generic message; it
now names the problem and shows `*<['counter']>::(int) += n`. A plain value
(`x += n` with `x = 1`) used to segfault orlyc in TMutation::GetValType,
which dereferences the target's mutable type unchecked; it now gets a clean
error. Both are pinned by new diagnostic lang_tests, and the two baselines
that quoted a compiler path are updated.
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.
Closes #557.
Before
After
What changed
TSourceErrorkeeps the throw site as a field (GetCodeLocation()) instead of splicing it intowhat(). Every one of the ~2000 throw sites already passed the location as its own argument, so onlyerror.hand the two print sites change.orlyc --compiler-locationsappends it.--debug/-dis taken, so this has its own flag.source_errorreplies carry it in a separatecompiler_lockey, soresultis a clean message. This is documented indocs/PROTOCOL.md.TImpossibleErrorkeeps it in the message, now with a space after it. For an internal compiler error the location is the report.TMutate::TypeCheckchecks this before running the operator's visitor:x += nwithx = 1) used to segfault orlyc with no output. On the releasedghcr.io/orlyatomics/orly:latestit exits with code 139 and prints nothing. The crash is inTMutation::GetValType, which doesAs<TMutable>()on the target's type and dereferences the result unchecked. It now gets a clean error.Tests
diag_mutate_addressanddiag_mutate_plain_value, added to.xfailunder Compiler diagnostics leak internal C++ source paths to users ([orly/type/add_visitor.h, 50]) #557 like the synth/expr/symbol: improve compiler diagnostic messages #314 pins.diag_assign_type_mismatchandsequence_in_effecting. The twocompile failure[orly/compiler.cc]lines come from a different error class that only prints under-d, so they are unchanged.lang_testin CI is the real check on their positions.