[DSLX] Factor out diagnostic routines, make test, add one diagnostic routine. #1827
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.
Now we give a more helpful explanation if you put a trailing semicolon in one block within an if/else ladder that gives an indication that users should see if that was intended. I observed it was common for folks to type an accidental trailing semi and then try to decipher why they were getting the error particularly if the consequent/alternate blocks were large.
xls/dslx/diagnostics/maybe_explain_error_test.cc
Conditional::GatherBlocks
is added to collect all the blocks participating in an if/else ladderAstNode::SetEncosing()
/GetEnclosing()
is added to supplement theparent()
relation -- because conditional nodes nest we want a direct (and easy) link to the "primordial" conditional in the ladder, and if you traversed parent() links you would have trouble telling when to stop (e.g. consider two nested conditional ladders) --parent()
relation is already completely defined as "tell me the node who claims me viaGetChildren()
" so we needed something new or a complicated traversal criterion