Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line and column numbers are wrong #738

Closed
HassanTaleb90 opened this issue Dec 24, 2023 · 3 comments
Closed

Line and column numbers are wrong #738

HassanTaleb90 opened this issue Dec 24, 2023 · 3 comments

Comments

@HassanTaleb90
Copy link

code: print(
output: 2:1: error: expected expression in list of expressions
expected: 1:7: error: expected expression in list of expressions

@kishikawakatsumi
Copy link
Member

This seems to be the expected result.

When the following command is executed,

$ sh -c "echo 'print(' | swift -"

The following output is obtained. This output matches the SwiftFiddle output.

<stdin>:2:1: error: expected expression in list of expressions

^

The same results are obtained when the following Swift file (test.swift) is created,

print(

and the following command is executed.

$ swift test.swift

@HassanTaleb90
Copy link
Author

Oh, I see. I tested only on https://www.jdoodle.com/execute-swift-online/.
Screenshot 2023-12-25 at 3 53 29 AM
It makes sense that the problem isn't in a line that doesn't exist yet.
How can we highlight errors if the line doesn't exist? 🤔 I think Xcode adds an extra line for that.
Screenshot 2023-12-25 at 4 00 55 AM

@kishikawakatsumi
Copy link
Member

Yes, Parser tries to find the closing bracket to the end of the file, so it will give an error for a line number that does not exist.
After the error is printed, you can add a line corresponding to the line number in error, for example, to get the expected result.

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

No branches or pull requests

2 participants