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

Fix error message on setter with wrong type #20444

Merged
merged 1 commit into from
May 23, 2024
Merged

Conversation

iusildra
Copy link
Contributor

@iusildra iusildra commented May 21, 2024

@@ -1334,12 +1334,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer

val setter = toSetter(lhsCore)
if setter.isEmpty then reassignmentToVal
Copy link
Member

Choose a reason for hiding this comment

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

When can setter actually be empty? We haven't found any such cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

When the pattern match in toSetter gets to the default case. But I am not sure this is ever the case. On the other hand, programs with parse errors can give uncommon trees, so better be defensive.

@mbovel
Copy link
Member

mbovel commented May 22, 2024

Test failure:

Output from 'tests/neg/i20338b.scala' did not match check file. Actual output:
-- [E007] Type Mismatch Error: tests/neg/i20338b.scala:10:8 ------------------------------------------------------------
10 |  f.x = 42 // error
        ^^
        Found:    (42 : Int)
        Required: String

 longer explanation available when compiling with `-explain`


Test output dumped in: tests/neg/i20338b.check.out
  See diff of the checkfile (`--color=always` for colored diff)
    > git diff --no-index -- tests/neg/i20338b.check tests/neg/i20338b.check.out
  Replace checkfile with current output
    > mv tests/neg/i20338b.check.out tests/neg/i20338b.check

The check file for i20338b seems to be incorrect.

Co-authored-by: Matt Bovel<[email protected]>
Co-authored-by: Nicolas Stucki<>
Co-authored-by: Hamza Remmal<>
Co-authored-by: Mehdi Alaoui<>

fix check file
@@ -1334,12 +1334,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer

val setter = toSetter(lhsCore)
if setter.isEmpty then reassignmentToVal
Copy link
Contributor

Choose a reason for hiding this comment

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

When the pattern match in toSetter gets to the default case. But I am not sure this is ever the case. On the other hand, programs with parse errors can give uncommon trees, so better be defensive.

@odersky odersky merged commit f99f268 into scala:main May 23, 2024
19 checks passed
@Kordyjan Kordyjan added this to the 3.5.1 milestone Jul 3, 2024
WojciechMazur added a commit that referenced this pull request Jul 9, 2024
Backports #20444 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
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.

Wrong error message when using setter extension method with wrong type
4 participants