Skip to content

Change diagnostic error thrown for when string interpolations aren't closed by a parenthesis #58882

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

Merged
merged 49 commits into from
Jun 4, 2022
Merged

Change diagnostic error thrown for when string interpolations aren't closed by a parenthesis #58882

merged 49 commits into from
Jun 4, 2022

Conversation

NSAntoine
Copy link
Contributor

This pull request changes the diagnostic error thrown when a string interpolation isn't closed by a parenthesis properly (ie: let x = "g \(")

Previously, it would blurt out unterminated string literal, with these changes it'll instead throw expected ')' at end of string interpolation

@NSAntoine NSAntoine marked this pull request as draft May 12, 2022 21:26
@NSAntoine
Copy link
Contributor Author

@hamishknight could you ask swift-ci to test this? once the test does succeed, ill add notes and fix-its, but i want to make sure this works first

@hamishknight
Copy link
Contributor

@swift-ci please test

@NSAntoine
Copy link
Contributor Author

NSAntoine commented May 12, 2022

CI down? nevermind

@NSAntoine
Copy link
Contributor Author

@hamishknight

@hamishknight
Copy link
Contributor

@swift-ci please test

@NSAntoine
Copy link
Contributor Author

@hamishknight okay this one should 100% work

@hamishknight
Copy link
Contributor

@swift-ci please test

@NSAntoine
Copy link
Contributor Author

Great! Now time to add the notes and fix its once I get home

@NSAntoine
Copy link
Contributor Author

@hamishknight

@hamishknight
Copy link
Contributor

@swift-ci please test

@NSAntoine
Copy link
Contributor Author

@hamishknight ninja: build stopped: subcommand failed. -- Warning: {} Host toolchain could not locate a compiler to build swift-driver.
Uhh.. can’t really be caused by us? Can it? It didn’t even get an opportunity to build the driver, so I assume it wasn’t even able to build swift itself

@hamishknight
Copy link
Contributor

hamishknight commented May 13, 2022

Looks like a legit error:

/Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/lib/Parse/Lexer.cpp:1896:13: error: expected expression
            .fixItInsert(Lexer::getSourceLoc(CurPtr), ")");
            ^

Usually it's good to search the CI logs for occurrences of error: , they can sometimes appear quite a bit further up the log. Jenkins is supposed to be able to detect things like this, but I guess not in this case.

@NSAntoine
Copy link
Contributor Author

Ohh, I see, I’ll fix just a sec

@NSAntoine
Copy link
Contributor Author

@hamishknight fixed, and I’ll take note of that, thanks!

@hamishknight
Copy link
Contributor

@swift-ci please test

@NSAntoine
Copy link
Contributor Author

@hamishknight this time could you test and ask it for a toolchain? I'm really sorry for all the trouble, but I can't compile locally unfortunately

@hamishknight
Copy link
Contributor

@swift-ci please test

@hamishknight
Copy link
Contributor

@swift-ci please build toolchain

@NSAntoine
Copy link
Contributor Author

@hamishknight Okay this should finally be it.. also, when it builds the toolchain, does it put the toolchain online for download?

@hamishknight
Copy link
Contributor

@swift-ci please test

@AnthonyLatsis
Copy link
Collaborator

If we've settled on the error also pointing to the opening paren, then let us merge the note into the error. I'm thinking cannot find ')' to match this opening '(' in string interpolation or similar.

@NSAntoine
Copy link
Contributor Author

Sure!

…closed, change message of string_interpolation_unclosed and update tests to reflect changes
@NSAntoine
Copy link
Contributor Author

@AnthonyLatsis ^

@AnthonyLatsis
Copy link
Collaborator

@swift-ci please build toolchain macOS

@NSAntoine
Copy link
Contributor Author

@AnthonyLatsis fixed the issues

@AnthonyLatsis
Copy link
Collaborator

@swift-ci please build toolchain macOS

@NSAntoine
Copy link
Contributor Author

@AnthonyLatsis

Command Output (stderr):
--
SIL verification failed: struct operand type does not match field type
  $Builtin.Int64
  $Builtin.Int32
Verifying instruction:
     %33 = integer_literal $Builtin.Int64, 714    // user: %34
->   %34 = struct $UInt (%33 : $Builtin.Int64)    // user: %102
     %102 = apply %101(%89, %25, %32, %34, %100) : $@convention(thin) (StaticString, StaticString, StaticString, UInt, UInt32) -> Never

This literally can't be related to us, can it?

@AnthonyLatsis
Copy link
Collaborator

@swift-ci please build toolchain macOS

@NSAntoine
Copy link
Contributor Author

@AnthonyLatsis this is so confusing.. I don’t think the SIL Error has anything to do with us though, could you just ask it to test only?

@AnthonyLatsis
Copy link
Collaborator

@swift-ci please smoke test macOS

@NSAntoine
Copy link
Contributor Author

@AnthonyLatsis could you ask it to build the toolchain again now?

@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented May 25, 2022

I will run validation tests first just in case. CI infographics indicate that the failure is non-deterministic, but the failure itself looks like it should be deterministic, which is a bit weird.

@swift-ci please test macOS

@AnthonyLatsis
Copy link
Collaborator

@eeckstein Could you take a look at this unrelated test failure?

https://ci.swift.org/job/swift-PR-toolchain-macos/164/console

@eeckstein
Copy link
Contributor

eeckstein commented May 25, 2022

Failed Tests (1):
  Swift-validation(watchsimulator-i386) :: SILOptimizer/hoist_destroy_addr.sil

@nate-chandler is this a fallout from the SSA destroy hoisting change (#58791)?

@nate-chandler
Copy link
Contributor

Already fixed via #59048 .

@nate-chandler
Copy link
Contributor

@swift-ci please build toolchain macOS

@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented May 25, 2022

Already fixed via #59048 .

Ah, now it makes sense — I was looking at the hoist_destroy_addr.sil in test, not validation-test. Thank you!

@NSAntoine
Copy link
Contributor Author

@AnthonyLatsis works locally! Ready for merge now?

@AnthonyLatsis
Copy link
Collaborator

We need a representative to review these changes first.

@AnthonyLatsis AnthonyLatsis requested a review from xedin May 26, 2022 15:42
@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented May 26, 2022

My only concern is that there is no discerning between an unterminated string inside the interpolation and a missing ), we just diagnose both issues unconditionally. We'd have to get more involved to make a difference though. Let's see what Pavel has to say.

@NSAntoine NSAntoine marked this pull request as ready for review May 30, 2022 11:11
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you all for the collaborative work on this one! Looks good to me! I have left a minor comment about the diagnostic itself inline. I'd also say that since "unterminated string literal" is not really a regression it could be improved separately.

@AnthonyLatsis
Copy link
Collaborator

@swift-ci please smoke test

@NSAntoine
Copy link
Contributor Author

@AnthonyLatsis tests passed; time for merge?

@AnthonyLatsis AnthonyLatsis merged commit e05f68c into swiftlang:main Jun 4, 2022
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

Successfully merging this pull request may close these issues.

6 participants