Repository navigation
Fix cyclic imports - #16
Merged
Merged
Conversation
Conflict in namify_common: main fixed the same naming bug (Name.declare strips trailing underscores) independently; main's version is taken. Example_tree_weight, new on main, is reseeded for values printed as cached functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Almost every module generated by the slow test suite failed to import: 203 of 204 in
generated_basic, all 204 ingenerated_full. CI never noticed, because the slow job only ranpy_compile.Each theory becomes a Python module, and code equations can use constants of later theories
(e.g.
Num.num_of_natis implemented byCode_Numeral.num_of_integer, which ends up inArith). So the generated modules import each other; in the HOL library about 50 of them formone import cycle. Python allows that, but module-level values such as
num_of_nat = Fun.comp(Arith.num_of_integer, ...)are evaluated during import and readattributes of modules that are still being imported:
A related problem: a value that calls a constant without code (e.g.
X = yot_literal(...)inCode_Test,uses_undefined = undefined) raised as soon as its module was imported.Changes
Values are printed as cached functions, and their uses call them:
Importing a module now evaluates nothing, so neither the cycles nor aborting constants can
break an import. Values are still evaluated only once. Aliases of functions (f_int = f)
remain ordinary functions.
Values of arity 2 or more (e.g. empty = (λ_ . None)) are printed as functions taking
all their arguments, since that is how callers call them. Before, they were curried lambdas,
and every call raised TypeError.
Applied lambdas are bracketed: (λx y. x) a b was printed as
(lambda xa: lambda : xa(a))(b), applying the body instead of the lambda.
Record name clash fixed: Name.declare drops a trailing underscore, so after declaring
point_ext the name still counted as free, and the records point, point' and point''
of HOL-Examples.Records all became point_ext. Names in use are now tracked separately.
Breaking change
Code that uses the generated modules must now call values: Example_nat.nat_sum() instead
of Example_nat.nat_sum.