enso-org / enso

Enso Analytics is a self-service data prep and analysis platform designed for data teams.
https://ensoanalytics.com
Apache License 2.0
7.37k stars 323 forks source link

Remove cycles from IR by migrating the type inference pass to use the `StaticModuleScope` metadata instead of `BindingsMap` #11509

Open radeusgd opened 6 days ago

radeusgd commented 6 days ago

In #11399 I'm introducing StaticModuleScope needed to be able to resolve method calls on atoms. It has some resemblance to BindingsMap but it is a bit 'higher-level' - instead of holding raw IR expressions, it contains type representations that are not part of raw IR. It was needed to reflect the runtime ModuleScope.

Since it's available, the resolution of atom constructors in type propagation could also rely on StaticModuleScope instead of BindingsMap. This will allow us to remove the added typReference expression from Argument type which will get rid of a problematic cycle in the IR. This should then fix an issue with duplicate that does not like cycles in the IR.

JaroslavTulach commented 6 days ago

I am facing the "cycle in IR" problem while working on

The cycle goes from Argument an cycles thru:

[error]     at org.enso.compiler.core.ir.Name$Literal.duplicate(Name.scala:531)
[error]     at org.enso.compiler.core.ir.Name$Literal.duplicate(Name.scala:474)
[error]     at org.enso.compiler.pass.resolve.TypeSignatures$Signature.duplicate(TypeSignatures.scala:369)
[error]     at org.enso.compiler.core.ir.MetadataStorage.duplicate(MetadataStorage.java:98)
[error]     at org.enso.compiler.core.ir.Name$Literal.duplicate(Name.scala:531)
[error]     at org.enso.compiler.core.ir.Name$Literal.duplicate(Name.scala:474)