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

Stainless crashs when using type aliases #1349

Closed
natsukagami opened this issue Dec 4, 2022 · 1 comment · Fixed by #1393
Closed

Stainless crashs when using type aliases #1349

natsukagami opened this issue Dec 4, 2022 · 1 comment · Fixed by #1393
Assignees
Labels

Comments

@natsukagami
Copy link

Stainless version: 0.9.7
Scala version: 3.2.0

Bug description

The following short code will crash Stainless:

import stainless.lang._
import stainless.collection._

type Index = BigInt

type LIndex = List[Index]

case class IndexedKey(index: BigInt, key: LIndex) {
  require(0 <= index && index < key.length)
}

Running stainless.sh Test.scala gives

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=lcd
[ Error  ] Stainless terminated with an error.
[ Error  ] Debug output is available in the file `stainless-stack-trace.txt`. If the crash is caused by Stainless, you may report your issue on https://github.com/epfl-lara/stainless/issues
[ Error  ] You may use --debug=stack to have the stack trace displayed in the output.

and stainless-stack-trace.txt is included.

Note that removing the stainless.collection._ import, the require line or changing LIndex to List[Index] will fix the crash.

@vkuncak
Copy link
Collaborator

vkuncak commented Mar 20, 2023

Here is perhaps slightly simpler example (without imports):

object Test {
  final case class Wrap[A](a: A) {
    def get: A = a
  }
  
  type WInt = Wrap[Int]

  case class IndexedKey(key: WInt) {
    require(key.get < 100)
  }  
}

May it be that the expansion of type aliases does not happen inside class invariants?

mario-bucev added a commit to mario-bucev/stainless that referenced this issue Mar 27, 2023
@mario-bucev mario-bucev mentioned this issue Mar 27, 2023
mario-bucev added a commit to mario-bucev/stainless that referenced this issue Mar 27, 2023
mario-bucev added a commit that referenced this issue Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants