Repository navigation
Report a syntax error at its line, not its column - #2
Merged
Merged
Conversation
TPasSyntaxTreeBuilder.Run turns an ESyntaxError into an ESyntaxTreeException, whose constructor takes the line first and the column second. It passed E.PosXY.X, E.PosXY.Y, but TmwBasePasLex.GetPosXY puts the column in X and the line in Y, so the two came out swapped. The EParserException path next to it was right; ParserMessage already passes Y, X. ESyntaxError is what ExpectedFatal raises, which is how an unexpected end of file is reported. A unit that stops after the `begin` of a routine on line 5 unit Broken; interface implementation procedure Run; begin was reported at line 6, col 5 instead of line 5, col 6.
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.
Bug.
TPasSyntaxTreeBuilder.Run(SourceStream)turns anESyntaxErrorintoESyntaxTreeException.Create(Line, Col, ...)but passedE.PosXY.X, E.PosXY.Y.TmwBasePasLex.GetPosXYputs the column inXand the line inY, so line and column were swapped. TheEParserExceptionpath next to it was already right, and so isParserMessage, which passesY, X.Repro.
ESyntaxErrorcomes fromExpectedFatal, which is how an unexpected end of file is reported:The exception reported line 6, col 5. It now reports line 5, col 6.
Fix. Pass
E.PosXY.Y, E.PosXY.X.Test.
Parser.UnexpectedEndOfFilePositionis added toTest/UnitTests. It fails onmain("Expected 5 but got 6") and passes with this change.