Closed apblack closed 5 years ago
The problem is that modules are treated specially. There is no $build
function, because it's not possible to inherit from a module. Instead, the code for a module is compiled by first installing all the methods, and then running the executable code.
Whether an AST node defines a method or not, and is executable or not, is specified by predicates on the various nodes. A typeDecNode
should now claim to be non-executable, rather than an executable node, and should be installed along with the methods. Then everything should happen in the correct order.
Fixed in commit b188d81
Test added in commit 38758e4
In gradualTypesND, the following declarations appear at the module level:
If written in the order above, all is fine. However, if the type declarations for
MethodType
andObjectType
are written after thedef scope ...
, then the initialization ofscope
fails. The methodMethodType
is invoked on the module object before to has been installed, and therefor fails.I'm not clear why this happens. The initialization of
scope
should take place as part of the module initialization, which should not occur until after the type methods have been installed.