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

Bad expected type on typeclass constraint #3498

Open
mtzguido opened this issue Sep 25, 2024 · 0 comments
Open

Bad expected type on typeclass constraint #3498

mtzguido opened this issue Sep 25, 2024 · 0 comments
Assignees
Labels

Comments

@mtzguido
Copy link
Member

module X

class usage_type (s:string) = {
  data_t: Type0;
  ps_data_t: data_t;
}

val get_data: s:string -> {|ut:usage_type s|} -> ut.data_t
let get_data s #ut = ut.ps_data_t

instance usage_string : usage_type "TLS.SigKey" = {
  data_t = int;
  ps_data_t = 42;
}

let test () : int =
  get_data "TLS.SigKey" #_

Minimized from an example from @TWal, somehow we get the error:

* Error 228 at X.fst(16,0-17,26):
  - Could not solve typeclass constraint `Type0`
  - See also FStar.Tactics.Typeclasses.fst(297,6-300,7)

1 error was reported (see above)

at the entrypoint of tcresolve (this should be clearer btw, the tactics aborts quickly since the goal is not a typeclass constraint, and that should be reflected in the error). Somehow the #_ was expected to have type Type0, instead of usage_type "TLS.SigKey". This incantation makes it work:

let test () : int =
  get_data "TLS.SigKey" #((_ by (FStar.Tactics.Typeclasses.tcresolve ())) <: usage_type "TLS.SigKey")
@mtzguido mtzguido self-assigned this Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant