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

With mix of packs and objects, ocamlc accepts wrong code or displays wrong error message #7359

Closed
vicuna opened this issue Sep 15, 2016 · 5 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Sep 15, 2016

Original bug ID: 7359
Reporter: sebmondet
Assigned to: @garrigue
Status: assigned (set by @xavierleroy on 2017-02-18T11:16:25Z)
Resolution: open
Priority: normal
Severity: minor
Target version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Monitored by: @hcarty

Bug description

This happened in big libraries and was difficult to spot (https://github.com/hammerlab/{ketrew,biokepi,epidisco}).
I have extracted the reproduction of the bug to 3 files that do not have dependencies:

https://gitlab.com/smondet/repro_ocaml_pack_problem

The reproduction there uses OCaml 4.02.3.

With 4.03.0, this seems partially fixed (?), at least in the same case we get an error but the error message still points at the wrong field:

$ File "mod_c.ml", line 5, characters 2-27:
Error: This expression has type Mod_a.product Lib_a.Mod_a.Container.t
It has no method product
Hint: Did you mean product?

(while the method that does not exist is path)

Not sure if this exhibits a deeper issue, or if it has been really fixed in 4.03.0.

@vicuna
Copy link
Author

vicuna commented Feb 18, 2017

Comment author: @xavierleroy

The repro case still fails in 4.05.0 beta.

Concerning the error, it definitely complains that "(Lib_b.Mod_b.get_mod_a p)" has no (visible) method named "product". The #path is not even typechecked. So, there are two independent questions here:

  • Why is t that the "suggestion" code sees a method named "product" while the type-checker does not?
  • Is it the case that there is no visible method named "product" here?

@garrigue could you please have a quick look at this issue? We'll probably move it to 4.06 anyway.

@vicuna
Copy link
Author

vicuna commented Oct 5, 2017

Comment author: @Octachron

If it helps, I have a somewhat simplified test case in https://github.com/Octachron/ocaml/tree/MPR7359/testsuite/tests/typing-pack .

@vicuna
Copy link
Author

vicuna commented Oct 19, 2017

Comment author: @gasche

This may slide into 4.07 if Jacques still doesn't have time to look at it.

@vicuna vicuna added the typing label Mar 14, 2019
@vicuna vicuna added this to the 4.06.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
@github-actions
Copy link

github-actions bot commented May 9, 2020

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@garrigue
Copy link
Contributor

Checking with trunk (before 4.12), the hint has disappeared. I don't know where it happened.

The error is still there, but it seems correct: the problem is the same module is used as packed for a value, and through the original cmi for a type. Since this type is structural, there is no error at this point. Later the type is no longer accessible, which makes it implicitly abstract, hence the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants