Skip to content
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

Avoid Null receiver values are not supported by libraries #8044

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Oct 13, 2023

Pull Request Description

Cannot query TypeOfNode for null.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • All code follows the
    Java,

@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Oct 13, 2023
@JaroslavTulach JaroslavTulach self-assigned this Oct 13, 2023
@JaroslavTulach
Copy link
Member Author

This was in the log:

java.lang.NullPointerException: Null receiver values are not supported by libraries.
        at org.graalvm.truffle/com.oracle.truffle.api.library.LibraryFactory.dispatch(LibraryFactory.java:528)
        at org.graalvm.truffle/com.oracle.truffle.api.library.LibraryFactory.getUncached(LibraryFactory.java:396)
        at org.enso.interpreter.runtime.library.dispatch.TypesLibraryGen$UncachedDispatch.hasType(TypesLibraryGen.java:397)
        at org.enso.interpreter.node.expression.builtin.meta.TypeOfNodeGen$Uncached.execute(TypeOfNodeGen.java:443)
        at org.enso.interpreter.service.ExecutionCallbacks.typeOf(ExecutionCallbacks.java:150)
        at org.enso.interpreter.service.ExecutionCallbacks.updateCachedResult(ExecutionCallbacks.java:91)
        at org.enso.interpreter.instrument.IdExecutionInstrument$IdEventNodeFactory$IdExecutionEventNode.onExpressionReturn(IdExecutionInstrument.java:175)
        at org.enso.interpreter.instrument.IdExecutionInstrument$IdEventNodeFactory$IdExecutionEventNode.onReturnValue(IdExecutionInstrument.java:156)

Copy link
Contributor

@hubertp hubertp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't have an example that caused it, do we?

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Oct 13, 2023

I have seen the problem while working on today's bookclub: Students_And_Courses.zip - not which revision was causing the problem however.

@JaroslavTulach JaroslavTulach merged commit b5d50e6 into develop Oct 13, 2023
35 checks passed
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/BookclubNpeCheck branch October 13, 2023 09:41
@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Oct 16, 2023

CCing @Akirathan

We probably don't have an example that caused it, do we?

I have another program that yields NullPointerException:

from Standard.Base import all

from Standard.Base.Data.Text import Extensions
from Standard.Table import all
from Standard.Database import all
from Standard.AWS import all
import Standard.Visualization

polyglot java import java.util.Random

main = 
    operator1 = Random.new

this yields error

Main.enso:9:1: error: Symbol 'Random' resolved ambiguously to 'java.util.Random' in the import Statement. The symbol was first resolved to 'Standard.Base.Random' in the import statement 'Main.enso[1:1-1:29]'.
    9 | polyglot java import java.util.Random
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

when executed from CLI. But in IDE it creates a ConstantNode with null value:

java.lang.NullPointerException: nullibution 24s
        at java.base/java.util.Objects.requireNonNull(Objects.java:209)
        at org.enso.interpreter.node.expression.constant.ConstantObjectNode.<init>(ConstantObjectNode.java:16)
        at org.enso.interpreter.node.expression.constant.ConstantObjectNode.build(ConstantObjectNode.java:26)
        at org.enso.compiler.codegen.IrToTruffle$ExpressionProcessor.nodeForResolution(IrToTruffle.scala:1685)
        at org.enso.compiler.codegen.IrToTruffle$ExpressionProcessor.processName(IrToTruffle.scala:1602)
        at org.enso.compiler.codegen.IrToTruffle$ExpressionProcessor.org$enso$compiler$codegen$IrToTruffle$ExpressionProcessor$$run(IrToTruffle.scala:1003)
        at org.enso.compiler.codegen.IrToTruffle$ExpressionProcessor.run(IrToTruffle.scala:991)
        at org.enso.compiler.codegen.IrToTruffle$CallArgumentProcessor.run(IrToTruffle.scala:2085)
        at org.enso.compiler.codegen.IrToTruffle$ExpressionProcessor.$anonfun$processApplicationWithArgs$2(IrToTruffle.scala:1999)

Fixed as #8061

mergify bot pushed a commit that referenced this pull request Oct 16, 2023
Prevents [this NullPointerException](#8044 (comment)) by making sure `ConstantNode` rejects `null` during construction.

# Important Notes
```ruby
from Standard.Base import all
polyglot java import java.util.Random

main =
operator1 = Random.new
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants