Skip to content

Allow var / let as parameter names, but provide a warning, and fixit to add backticks. #24059

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 3 commits into from
Apr 26, 2019

Conversation

sl
Copy link
Contributor

@sl sl commented Apr 16, 2019

Notable Changes

  • Allows var / let to be used as parameter names as there's no reason to disallow this now
  • Added a diagnostic recommending that people escape var / let used as keywords in function declarations. No escaping is recommended at the call site as there is no possible ambiguity regarding the possible behavior of let / var there.
  • Removed let and var from the warning regarding multiple specifiers
  • Updated tests to reflect the new behavior, and added new tests ensuring the new warning is properly generated

Resolves SR-10293.
This is resolved as there's no longer a need to change that fixit.

@sl sl requested a review from xedin April 16, 2019 16:11
@theblixguy
Copy link
Collaborator

Looks like #24025

@CodaFi
Copy link
Contributor

CodaFi commented Apr 16, 2019

If you wish to take over this bug, please see my notes on the other. In brief: please don’t change the diagnostic engine, but instead remove this diagnostic and make it do something useful by sticking in backquotes.

@sl
Copy link
Contributor Author

sl commented Apr 17, 2019

Just pushed a change that allows let / var as argument label names but generates a warning when they're used. I'm going to have to update a lot of tests that rely on this being disallowed so don't run CI just yet, but I figured I'd put this up so anyone interested can take a look at the implementation. I'll modify the tests relating to this so they expect the new warning rather than the old error tomorrow.

Just as a note on the implementation, doing this was a tad bit more involved than just changing the error to a warning and shuffling around tests as there were a few conflicting diagnostics that would yell at you if you added backticks to something that wasn't invalid without them. I modified those diagnostics so they don't fire when we want to allow both with and without backticks.

@sl sl changed the title Fixit for var / let as parameter doesn't remove enough whitespace. Allow var / let as parameter names, but provide a warning and fixit to add backticks. Apr 17, 2019
@sl sl changed the title Allow var / let as parameter names, but provide a warning and fixit to add backticks. Allow var / let as parameter names, but provide a warning, and fixit to add backticks. Apr 17, 2019
@sl
Copy link
Contributor Author

sl commented Apr 18, 2019

@swift-ci build toolchain

1 similar comment
@xedin
Copy link
Contributor

xedin commented Apr 18, 2019

@swift-ci build toolchain

@sl
Copy link
Contributor Author

sl commented Apr 18, 2019

@swift-ci please smoke test

@swift-ci
Copy link
Contributor

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - 83c0a794da739bdb6b284c6c7252fdd709a332d3

Install command
tar zxf swift-PR-24059-231-ubuntu16.04.tar.gz
More info

@sl
Copy link
Contributor Author

sl commented Apr 25, 2019

@swift-ci please smoke test

@sl
Copy link
Contributor Author

sl commented Apr 25, 2019

@swift-ci build toolchain

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.

LGTM! Thank you, @sl!

@xedin
Copy link
Contributor

xedin commented Apr 26, 2019

@swift-ci please test source compatibility

sl added 3 commits April 26, 2019 04:07
The diagnostic is now a warning and the new message alerts the user that
though it is valid to have let and var as argument label names,
they are interpreted as argument labels, not keywords.
@sl
Copy link
Contributor Author

sl commented Apr 26, 2019

@swift-ci please smoke test

@sl
Copy link
Contributor Author

sl commented Apr 26, 2019

@swift-ci please test source compatibility

@sl sl merged commit 3d9b639 into swiftlang:master Apr 26, 2019
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.

5 participants