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

Blocking bug: some graders fail with Error: Ctype.Unification_trace.Unify(_) #457

Closed
erikmd opened this issue Nov 4, 2021 · 3 comments · Fixed by #461
Closed

Blocking bug: some graders fail with Error: Ctype.Unification_trace.Unify(_) #457

erikmd opened this issue Nov 4, 2021 · 3 comments · Fixed by #461
Assignees

Comments

@erikmd
Copy link
Member

erikmd commented Nov 4, 2021

Related project scope(s) (ex: client, CSS, grading, etc...) : grading
Related user(s): @erikmd

Bug description

I noticed this week a regression:
some graders of my lab sessions (relying on and extending code from Test_lib, so involving direct calls to Introspection) worked fine with 0.12 but now fail noisily with 0.13.x with the following error:

Learnocaml v.0.13.1 running.
Updating app at ./www
Exercise definition error while testing your solution:
File "_none_", line 1:
                                                       Error: Ctype.Unification_trace.Unify(_)


grader outcomes:
val print_html : 'a -> 'b = <fun>
module Code :
(…)

To Reproduce

I was able to craft a minimal working example:

  • Add just the following code in an existing test.ml:
module type tARITH_TEACHER = sig
  type t
  val zero : t
  val one : t
  val add : t -> t -> t
  val mul : t -> t -> t
  val opp : t -> t
  val of_int : int -> t
  val to_string : t -> string
end

(* dummy but sufficient example to reproduce the failure *)
let foo0 () = Introspection.get_value "INT" [%ty: (module tARITH_TEACHER)]
  • then you'll get a failure with 0.13.1.

@AltGr, would you have an idea to isolate/fix the issue?

I hope this could be fixed or workarounded (so that the grader behaves the same as with 0.12).

Current configuration

  • OS: GNU/Linux
  • Browser: Firefox
  • Version: learn-ocaml 0.13.1
@erikmd
Copy link
Member Author

erikmd commented Nov 4, 2021

I skimmed the compiler-libs code, so it seems the error comes from a call to the unify function:

https://github.com/ocaml/ocaml/blob/46c947827ec2f6d6da7fe5e195ae5dda1d2ad0c5/typing/ctype.ml#L3114-L3121

But I can't see where the exception Ctype.Unification_trace.Unify would be un-caught in learn-ocaml's code after the 4.12 migration… hoping @AltGr will have some hints

@lsylvestre
Copy link
Contributor

lsylvestre commented Nov 8, 2021

Hi @erikmd,
Hi @AltGr,

Here is another example:

let x = 10 ;;
let v = Introspection.get_value "x" [%ty: int] ;;

It produces the following trace:

Exercise definition error while testing your solution:
File "_none_", line 1:
                                                       Error: Ctype.Unification_trace.Unify(_)
...
module Test_lib : Test_lib.S
module Report = Learnocaml_report
val x : int = 10
demo                       [FAILED]

Workaround

Like this, it works:

module I = Introspection

let x = 10 ;;
let v = I.get_value "x" [%ty: int] ;;
module Introspection = Introspection

module type tARITH_TEACHER = sig
  type t
  val zero : t
  val one : t
  val add : t -> t -> t
  val mul : t -> t -> t
  val opp : t -> t
  val of_int : int -> t
  val to_string : t -> string
end

let foo0 () = Introspection.get_value "INT" [%ty: (module tARITH_TEACHER)]

Strange, isn't it?

So, to fix (temporarily) the problem, you can add the following code:

      handle_error (internal_error [%i"while preparing the tests"]) @@
      Toploop_ext.use_string ~print_outcome ~ppf_answer
        "module Introspection = Introspection" ;

to the file: https://github.com/ocaml-sf/learn-ocaml/blob/master/src/grader/grading.ml#L143

have a good day,

Loïc

@erikmd
Copy link
Member Author

erikmd commented Nov 8, 2021

Thanks a lot, @lsylvestre ! ✨

I'll merge your workaround now to be able to use ocamlsf/learn-ocaml:master;
(and we'll be able to refine the fix later on if need be - I added a comment in the code)

erikmd added a commit to pfitaxel/learn-ocaml that referenced this issue Nov 8, 2021
Graders using module `Introspection` (which used to work with 0.12)
should now work with `ocamlsf/learn-ocaml:master` as well, i.e., they
should not raise `Ctype.Unification_trace.Unify(_)` any longer.

href: ocaml-sf#457 (comment)
erikmd added a commit that referenced this issue Nov 8, 2021
…461)

Graders using module `Introspection` (which used to work with 0.12)
should now work with `ocamlsf/learn-ocaml:master` as well, i.e., they
should not raise `Ctype.Unification_trace.Unify(_)` any longer.

href: #457 (comment)
@erikmd erikmd added this to the learn-ocaml 0.14.0 milestone Nov 8, 2021
@erikmd erikmd self-assigned this Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants