Skip to content

Hygiene of constructor default args is not per spec #22700

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

Open
som-snytt opened this issue Mar 3, 2025 · 0 comments
Open

Hygiene of constructor default args is not per spec #22700

som-snytt opened this issue Mar 3, 2025 · 0 comments

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.6.3

Minimized code

//import Settings.*

object Settings {
  def x = 0
}

case class Settings(value: Double = x)

Output

  snips scala-cli compile --server=false -S 2.13.16 default-arg-hygiene.scala
/home/amarki/snips/default-arg-hygiene.scala:8: error: not found: value x
case class Settings(value: Double = x)
                                    ^
1 error
Compilation failed
  snips scala-cli compile --server=false -S 3.6.3 default-arg-hygiene.scala
  snips

Expectation

Obviously, x is not visible at the default arg. Successful compilation is an artifact of bad hygiene.

Expect (and require) an error as in Scala 2.

Observed at #22690 (comment)

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 3, 2025
@Gedochao Gedochao added area:default-parameters and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 4, 2025
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

2 participants