Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007620OCamlcompiler driverpublic2017-09-05 02:552017-09-13 01:41
Reporterfuruse 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.05.0 
Target VersionFixed in Version4.06.0 +dev/beta1/beta2/rc1 
Summary0007620: Typecore.force_delayed_checks does not run with -i option.
DescriptionThe following program passes ocamlc -i, but not ocamlc:

----------
let t =
  (function `A | `B -> () : 'a) (`A : [`A]);
  (failwith "dummy" : 'a) (* to know how 'a is unified *)
----------

With ocamlc -i,

----------
val t : [ `A ] -> unit
----------

but with ocamlc

----------
File "x.ml", line 2, characters 17-19:
Error: This pattern matches values of type [? `B ]
       but a pattern was expected which matches values of type [ `A ]
       The second variant type does not allow tag(s) `B
----------

This is because Typecore.force_delayed_checks never runs when -i option is given.

There is another issue of Typecore.force_delayed_checks: it runs only after printing the module signature in Compile.interface and Optcompile.interface.

I think they are bugs, but are they done intentionally? Even if they are intentional, Typecore.force_delayed_checks must run after printing the signatures for ocamlc -i.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0018219)
garrigue (manager)
2017-09-05 14:04

This is clearly a bug. Going to fix it.
(0018220)
garrigue (manager)
2017-09-05 14:26

Actually, this is more complicated than I thought:
force_delayed_checks is also used for unused definition warning, which is dependent on the presence of an mli.
This is why it was moved outside of the -i path.
The answer is probably that we should disable unused definition warnings when -i is used...
Alain, any comment?
(0018223)
garrigue (manager)
2017-09-05 16:03

Tentative fix: https://github.com/ocaml/ocaml/pull/1317 [^]
(0018228)
furuse (reporter)
2017-09-06 02:29
edited on: 2017-09-06 03:42

BTW, why is it handled as a type error? Is there an example to break the type safety by changing it to a warning?

FYI, the example was found in a use of ppx_implicits, where, roughly speaking, pre-process a typed code, for example, from

(function `A | `B -> ()) (assert false)

to

(function `A | `B -> ()) (`A : [`A])

It relies heavily on the principal type property, but it is broken here...

(0018243)
garrigue (manager)
2017-09-13 01:38

Fixed in trunk by commit e286dbd7.
Call Typecore.force_delayed_checks before printing the signature for ocamlc -i.
(0018244)
garrigue (manager)
2017-09-13 01:41

@furuse, is your question about the fix, or about the original behavior?

Note that the value restriction breaks the principal type property from the beginning (non-generalizable type variables are not allowed to remain in compilation units).

- Issue History
Date Modified Username Field Change
2017-09-05 02:55 furuse New Issue
2017-09-05 14:04 garrigue Note Added: 0018219
2017-09-05 14:04 garrigue Assigned To => garrigue
2017-09-05 14:04 garrigue Status new => confirmed
2017-09-05 14:26 garrigue Note Added: 0018220
2017-09-05 16:03 garrigue Note Added: 0018223
2017-09-06 02:29 furuse Note Added: 0018228
2017-09-06 02:52 furuse Note Edited: 0018228 View Revisions
2017-09-06 02:52 furuse Note Edited: 0018228 View Revisions
2017-09-06 03:42 furuse Note Edited: 0018228 View Revisions
2017-09-13 01:38 garrigue Note Added: 0018243
2017-09-13 01:38 garrigue Status confirmed => resolved
2017-09-13 01:38 garrigue Fixed in Version => 4.06.0 +dev/beta1/beta2/rc1
2017-09-13 01:38 garrigue Resolution open => fixed
2017-09-13 01:41 garrigue Note Added: 0018244


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker