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

packed modtype lookup can fail due to missing cmi #9409

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

Octachron
Copy link
Member

@Octachron Octachron commented Mar 31, 2020

Closes #9406:

This PR makes module types from missing cmis behaves the same as abstract module type everywhere.

This was already the case in nearly all cases, except for a forgotten case in the function Typemod.modtype_of_package.

After this change, there is no call site of Env.find_modtype that distinguish between the case None and exception Not_found. It would probably make sense to fold the two cases into one.

@Drup
Copy link
Contributor

Drup commented Mar 31, 2020

Sounds good. This fixes the bug and make the behavior consistent again. The patch and tests look fine.

I would prefer if missing cmis were actually an error, but that's a contentious topic for another time. :)

@gasche
Copy link
Member

gasche commented Mar 31, 2020

It would probably make sense to fold the two cases into one.

You are proposing that Env.find_modtype would never raise Not_found and only return None? (Are you planning to submit a PR?)

@Octachron
Copy link
Member Author

Rereading the code, it would rather be a version of find_modtype_expansion that returns an option rather than raise a Not_found exception.

Maybe, we could split find_modtype into find_modtype_decl for finding the declaration of the module type and find_modtype for looking up just the type with the Not_found -> abstract translation.
I am willing to submit a PR if we agree on a design.

@Octachron
Copy link
Member Author

Reviewing the fix, I would prefer to start with integrating the current bugfix PR (to integrate the test) before potentially moving on to a refactoring PR.

Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks obviously correct. Approving. This is good to go if the CI passes and the patchset is rebased appropriately, please feel free to merge. (I will probably forget to do it myself.)

@Octachron Octachron force-pushed the yet_another_implicit_deps_error branch 2 times, most recently from f55ba91 to e724b37 Compare April 16, 2020 16:49
This commit removes an assert false and makes the missing
cmi case behaves like the abstract case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File "typing/typemod.ml", line 1817, characters 27-33: Assertion failed
3 participants