-
Notifications
You must be signed in to change notification settings - Fork 323
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
Infer method calls on known types and warn about nonexistent methods #11399
Conversation
…tion no longer in outer layer
…ce tests Ideally, the static analysis tests should be runnable without the Graal runtime context. We'd like to be able to run these static passes without Graal runtime, e.g. inside of code editors. But refactoring import resolution and PackageRepository to work without Graal is out of scope of the current types work. It can be planned for later, when needed. For now the focus is to make type checking provide actual value - before that any editor integration wouldn't be useful anyway.
I think I tried addressing all of the comments. I will very much appreciate your reviews on this next iteration of the PR. Sorry it is happening after such a long time - I will try to schedule time to iterate on this PR faster this time. |
@Akirathan suggested to remove his `validateConsistency` check, but I've found I could fix the asserts by caching the returned value in persisted Map (if there was no caching, then on every ir.passData().get(...) a new instance of metadata was recreated, so the `validateConsistency` was failing because it requires object _identity_ and not only equality). We can either keep this 'cache' or remove Pavel's check.
This reverts commit 9d5deaa.
# Conflicts: # engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala
I'm getting weird test failures in
Interestingly, it seems that my followup PR #11955 that removes the @JaroslavTulach do you think we can merge both PRs at once (I need to finish the followup but I'm working on that) OR would you like to help me investigating this serialization issue? Seems like there is still some issue in the persistance when cycles are around. IMO it will be easier to just merge the followup, although we can also try investigating the persistance to make it more robust as such failures probably shouldn't be happening - but I don't think fixing persistance should be the focus of this PR in more extent than necesary. |
…s (no parameter type mismatch checks yet, instead testing method mismatch)
I wanted to keep these PRs separate but it initially (I'm waiting for full CI suite to pass to verify) seems that the followup PR #11955 is fixing the persistance issues that are causing test failures in this PR. So I think ideally I'd merge #11955 into this PR and then merge the whole changeset as a single change. I'm not merging yet so that you can review more easily - first my answers to your requests in this PR and then the followup PR that builds on top of it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the abstraction of algorithms into singletonizers and their usage is correct. I don't feel completely qualified to talk about the static analysis, but I left few comments inline. If the CI is green, then I am for integrating these changes.
...e/runtime-compiler/src/main/java/org/enso/compiler/common/BuildScopeFromModuleAlgorithm.java
Outdated
Show resolved
Hide resolved
...e/runtime-compiler/src/main/java/org/enso/compiler/common/BuildScopeFromModuleAlgorithm.java
Show resolved
Hide resolved
engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/BuiltinTypes.java
Outdated
Show resolved
Hide resolved
...me-compiler/src/main/java/org/enso/compiler/pass/analyse/types/TypeInferencePropagation.java
Outdated
Show resolved
Hide resolved
engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/BuiltinTypes.java
Outdated
Show resolved
Hide resolved
* @param useGlobalCacheLocations whether or not the compilation result should | ||
* be written to the global cache | ||
* @return future to track subsequent serialization of the library | ||
*/ | ||
def compile( | ||
shouldCompileDependencies: Boolean, | ||
shouldWriteCache: Boolean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is a reasonable way to avoid the static type information to be stored in the caches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, plus IIRC it fixes a weird behaviour - that even if caches were disabled, they would still be written after compilation or something.
Now, if we run --no-ir-cache
, we neither read nor write the caches, which I think is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why we are seeing failures like https://github.com/enso-org/enso/actions/runs/12680614808/job/35342759884?pr=12023#step:7:2875 is probably because of this nor write behavior. Previously there was one failing run and the bad caches would get overwritten. Now the bad caches stick there forever.
That's rational, but looks like the
Line 129 in cb72487
throw new AssertionError("Unexpected output (errors?) from the compiler: " + out.toString()); |
may not be ready for that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh...
Can't we just run the engine with --compile
to write the new caches, before running this bench?
engine/runtime-compiler/src/main/scala/org/enso/compiler/context/InlineContext.scala
Outdated
Show resolved
Hide resolved
* | ||
* <p>Ideally, the tests for the static analysis capabilities of the compiler should _not_ depend | ||
* on the Graal runtime context, as they should be runnable in other contexts - i.e. in a Visual | ||
* Studio Code language server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would indeed be ideal! The integration of the runtime-compiler
into VSCode is blocked right now because we have no way to run the runtime-compiler
without TruffleCompilerContext
right now. If only these tests could be moved to runtime-compiler
project test directory! Then:
- they wouldn't depend on
TruffleCompilerContext
- they would need an independent compiler context implementation
- such an implementation could be used in VSCode as well
I remember @Akirathan was once dreaming about using runtime-compiler
in VSCode and this was a huge "known unknown".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think ideally we should move them there - it seems like the right direction.
But implementing the independent compiler context is definitely a task for a separate PR.
engine/runtime-integration-tests/src/test/java/org/enso/compiler/test/StaticAnalysisTest.java
Outdated
Show resolved
Hide resolved
…atom type resolution (#11955)
In 6b0ce25 I merged the followup PR so that we can merge them both to develop in one try. I will proceed with merging once CI gets green. |
I've ran the benchmarks and tried comparing against develop: It's really quite hard to tell in each benchmark if any deviations are just due to benchmark instability or real regression (how are you guys managing to live without seeing the standard deviation error bars on the measurements? 😮). Here are a few 'more concerning' results I saw: Still they don't seem bad, so I think I will proceed with merging. |
Pull Request Description
Any
) type that does not exist on that type, a warning is reported, because such a call would always result inNo_Such_Method
error at runtime.Any
has special behaviour - ifx : Any
we don't know whatx
might be, so we allow all methods on it and defer to the runtime to see if they will be valid or not.BindingsMap
by instead relying onStaticModuleScope
for atom type resolution #11955:AtomTypeInterface
,TypeRepresentation
to be a plain data structure,BindingsMap
in favour of relying onStaticModuleScope
.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.