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

Generic domain function application needs trivial type variable map with uninsightful error message #733

Open
nilscrm opened this issue Aug 16, 2023 · 0 comments

Comments

@nilscrm
Copy link

nilscrm commented Aug 16, 2023

If one wants to create a simple generic domain to represent an option type, one could use this (simplified) example:

domain Option[T]  {

  function none_val(): Option[T]

  function some_of(x: T): Option[T]

  axiom {
    (forall x: T :: { some_of(x) } some_of(x) != none_val())
  }
}

This works perfectly fine in VS Code, however, when one want to implement this in Silver, troubles can occur.
The generic function call some_of(x) can be modeled as

vpr.DomainFuncApp(someOf, Seq(vpr.LocalVar("x", T)()), Map.empty)()

This code, however, throws an exception:

java.lang.Exception: Internal error in type system - unexpected non-ground type <T>

It is non-obvious from this error that the actual problem is the empty type variable map. Even in the generic case where you want to keep the generic type T a type variable map from T to T needs to be specified like this:

vpr.DomainFuncApp(someOf, Seq(vpr.LocalVar("x", T)()), Map(T -> T))()

Two possible solution might be to either have a default value for the type variable map or to make the error message clearer.

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

No branches or pull requests

1 participant