Skip to content

Function equality (and difference) does not throw exception #584

@jmid

Description

@jmid

Consider the program

  let m = (=) (fun g -> "") (fun v -> "") in 0

If I compile it to ocaml bytecodes and run it it raises an exception as expected:

$ ocamlc -o issues/eqfun.byte ./issues/eqfun.ml 
File "./issues/eqfun.ml", line 2, characters 6-7:
Warning 26: unused variable m.
$ ./issues/eqfun.byte 
Fatal error: exception Invalid_argument("compare: functional value")
$ 

However with js_of_ocaml the exception disappears:

$ js_of_ocaml -o issues/eqfun.js issues/eqfun.byte 
$ node issues/eqfun.js 
$ 

There is a similar issue with the difference operator, e.g., if I change (=) to (<>) in the above example I observe the same difference in behaviour. However with, e.g., the operator compare js_of_ocaml will produce code that raises an exception.

This is with ocaml version 4.04.0, js_of_ocaml version 2.8.4, and node version 6.10.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions