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

[SR-14221] Add tricky parsing test case. #56597

Closed
typesanitizer opened this issue Feb 15, 2021 · 8 comments
Closed

[SR-14221] Add tricky parsing test case. #56597

typesanitizer opened this issue Feb 15, 2021 · 8 comments

Comments

@typesanitizer
Copy link

@typesanitizer typesanitizer commented Feb 15, 2021

Previous ID SR-14221
Radar rdar://problem/74366546
Original Reporter @typesanitizer
Type Task
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Task, StarterBug
Assignee None
Priority Medium

md5: 7a6db14dd0d359bf7788331e075f0452

Issue Description:

struct S {
    var x : Int = f() {
        3
    }
}

This is interpreted as a trailing closure, instead of being interpreted as an error where you are trying to have a computed property with an initial value (computed properties don't have initial values).

We should check if the test/Parse directory has a test case which checks for this. If not, we should add this test case and leave a comment indicating why this test case is present.

@typesanitizer
Copy link
Author

@typesanitizer typesanitizer commented Feb 15, 2021

Feel free to ping me on GitHub for review (@ varungandhi-apple), or ask questions here.

@typesanitizer
Copy link
Author

@typesanitizer typesanitizer commented Feb 15, 2021

@swift-ci create

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Feb 26, 2021

Comment by Hongjing Chen (JIRA)

Hello, can I try to work on this as my first contribution? theindigamer (JIRA User)

Hope I don't misunderstand what you mean. I have some quetions. The correct thing is that the code should be regareded as a trailing closure, right? Do we expect an error to occur when testing?

@typesanitizer
Copy link
Author

@typesanitizer typesanitizer commented Feb 26, 2021

The correct thing is that the code should be regareded as a trailing closure, right?

Yes, that's correct.

Do we expect an error to occur when testing?

We don't expect any error to happen during testing, but the reason to add the test case (in case it doesn't exist already) is to avoid regressing this edge case when changing the parser. Sometimes one might forget to realize all the edge cases that one needs to consider, and make some change assuming that it won't break anything, but in reality there is some edge case which does break. So it's helpful to have tests for edge cases even if the code is working alright.

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Feb 27, 2021

Comment by Hongjing Chen (JIRA)

Thanks. I’ll check if it needs to be added.

@typesanitizer
Copy link
Author

@typesanitizer typesanitizer commented Mar 1, 2021

PR opened by Hongjing: #36202

@xAlien95
Copy link
Contributor

@xAlien95 xAlien95 commented Mar 30, 2021

theindigamer (JIRA User), can this be closed now since the PR has been merged?

@typesanitizer
Copy link
Author

@typesanitizer typesanitizer commented May 16, 2021

Thanks Stefano, yeah, we can close this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants