Closed ameliatastic closed 1 year ago
The first commit makes some progress in allowing prelude to be auto-imported + unexported. Still need to resolve how imports work with other modules like seahorse.pyth
.
Imports created by the namespace stage are wrapped in a cleaner struct now, which includes information about whether the import references a builtin item or not. This makes it possible for these imports to be pruned out of the generated use
statements!
The "stealth fix" is due to a bug that was introduced by the expression context update 😬
Basically the Pyth validate_price_feed
method didn't work at all, because it expected a string literal but it was being passed a string.to_string()
. Easy fix is to just add the Seed
context, which actually lets string literals show up as string literals.
See thread in Discord.
The general problem is that Seahorse-builtin objects like everything in
seahorse.prelude
are treated like normal imports. If you have a module that doesfrom seahorse.prelude import *
, then you import everything in that module from another module (from my_module import *
), then it will carry the prelude names with it. This could cause a bug at compile time, since the compiler didn't know how to handle builtin objects that come from a different module.We discussed the best solutions in Discord and decided that
prelude
could just be imported automatically but not exported (like Python builtins), and then still allow other builtins to be re-exported. So there's essentially three cases for imports:seahorse.prelude
(u64, Account, etc.
) and Python builtins (str, min, max, etc.
)seahorse.pyth
Closes #57