-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when named tuples resemble assignments
Co-Authored-By: Nicolas Stucki <3648029+nicolasstucki@users.noreply.github.com> Co-Authored-By: Oliver Bračevac <bracevac@users.noreply.github.com>
- Loading branch information
1 parent
6e32627
commit 8566f53
Showing
7 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- [E203] Syntax Migration Warning: tests/warn/21681.scala:4:2 --------------------------------------------------------- | ||
4 | (age = 29) // warn | ||
| ^^^^^^^^^^ | ||
| Ambiguous syntax: this is interpreted as a named tuple with one element, | ||
| not as an assignment. | ||
| | ||
| To assign a value, use curly braces: `{age = 29}`. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def main() = | ||
var age: Int = 28 | ||
(age = 29) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- [E203] Syntax Migration Warning: tests/warn/21770.scala:5:9 --------------------------------------------------------- | ||
5 | f(i => (cache = Some(i))) // warn | ||
| ^^^^^^^^^^^^^^^^^ | ||
| Ambiguous syntax: this is interpreted as a named tuple with one element, | ||
| not as an assignment. | ||
| | ||
| To assign a value, use curly braces: `{cache = Some(i)}`. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def f(g: Int => Unit) = g(0) | ||
|
||
def test = | ||
var cache: Option[Int] = None | ||
f(i => (cache = Some(i))) // warn |