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

FragmentChecker should reject secondary constructor #1352

Closed
mario-bucev opened this issue Dec 7, 2022 · 0 comments · Fixed by #1354
Closed

FragmentChecker should reject secondary constructor #1352

mario-bucev opened this issue Dec 7, 2022 · 0 comments · Fixed by #1354

Comments

@mario-bucev
Copy link
Collaborator

The following snippet is accepted, but it should be rejected because we do not handle secondary constructors at the moment:

object FragmentChecker {
  case class Test(val smth: Int, val other: Int) {
    def this(smth: Int) = this(smth, 42)
  }

  def test(x: Int) = {
    val t = new Test(x)
  }
}

We get a strange well-formedness error:

[ Error  ] FragmentChecker.scala:9:5: Type error: val t$63: Test$0 = Test$0(x$99)
[ Error  ] (), expected Unit,
[ Error  ] found <untyped>
[ Error  ] 
[ Error  ] Typing explanation:
[ Error  ] val t$63: Test$0 = Test$0(x$99)
[ Error  ] () is of type <untyped>
[ Error  ]   Test$0(x$99) is of type <untyped>
[ Error  ]     x$99 is of type Int
[ Error  ]   () is of type Unit
               val t = new Test(x)
               ^^^^^^^^^^^^^^^^^^^^
mario-bucev added a commit to mario-bucev/stainless that referenced this issue Dec 7, 2022
mario-bucev added a commit to mario-bucev/stainless that referenced this issue Dec 7, 2022
@mario-bucev mario-bucev linked a pull request Dec 7, 2022 that will close this issue
vkuncak pushed a commit that referenced this issue Dec 8, 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 a pull request may close this issue.

1 participant