question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swapping `def x` and `def y` of implicit2.aya causes NPE

See original GitHub issue

implicit2.aya:

open data Unit : Set | unit

def y : Pi {a : Unit} -> Unit => \{a} => a
def x : Pi {a : Unit} -> Unit => y
def z : Pi {a : Unit} -> Unit => x

It does not typecheck as expected.

But a slightly different version causes NPE

open data Unit : Set | unit

def x : Pi {a : Unit} -> Unit => y
def y : Pi {a : Unit} -> Unit => \{a} => a
def z : Pi {a : Unit} -> Unit => x

stacktrace:

    java.lang.NullPointerException
        at java.base/java.util.Objects.requireNonNull(Objects.java:208)
        at org.aya.core.def.Def.defLevels(Def.java:39)
        at org.aya.tyck.ExprTycker.levelStuffs(ExprTycker.java:277)
        at org.aya.tyck.ExprTycker.defCall(ExprTycker.java:265)
        at org.aya.tyck.ExprTycker.inferRef(ExprTycker.java:231)
        at org.aya.tyck.ExprTycker.doVisitRef(ExprTycker.java:223)
        at org.aya.tyck.ExprTycker.visitRef(ExprTycker.java:212)
        at org.aya.tyck.ExprTycker.visitRef(ExprTycker.java:57)
        at org.aya.concrete.Expr$RefExpr.doAccept(Expr.java:244)
        at org.aya.concrete.Expr.accept(Expr.java:41)
        at org.aya.tyck.ExprTycker.checkNoZonk(ExprTycker.java:125)
        at org.aya.tyck.ExprTycker.lambda$checkNoZonk$2(ExprTycker.java:123)
        at org.aya.tyck.LocalCtx.with(LocalCtx.java:62)
        at org.aya.tyck.LocalCtx.with(LocalCtx.java:47)
        at org.aya.tyck.ExprTycker.checkNoZonk(ExprTycker.java:122)
        at org.aya.tyck.ExprTycker.checkExpr(ExprTycker.java:135)
        at org.aya.tyck.StmtTycker.lambda$visitFn$8(StmtTycker.java:184)
        at kala.control.Either$Left.map(Either.java:166)
        at org.aya.tyck.StmtTycker.visitFn(StmtTycker.java:183)
        at org.aya.tyck.StmtTycker.visitFn(StmtTycker.java:43)
        at org.aya.concrete.stmt.Decl$FnDecl.doAccept(Decl.java:324)
        at org.aya.concrete.stmt.Decl.accept(Decl.java:70)
        at org.aya.concrete.stmt.Decl.tyck(Decl.java:61)
        at org.aya.concrete.resolve.module.FileModuleLoader.tyckModule(FileModuleLoader.java:99)
        at org.aya.cli.single.SingleFileCompiler.compile(SingleFileCompiler.java:51)
        at org.aya.test.TestRunner.runFile(TestRunner.java:66)
        at org.aya.test.TestRunner.lambda$runDir$2(TestRunner.java:55)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
        at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.aya.test.TestRunner.runDir(TestRunner.java:55)
        at org.aya.test.TestRunner.runAllAyaTests(TestRunner.java:44)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
re-xyrcommented, Aug 28, 2021

I think this demonstrates sometimes you want to use Option - they require you to unwrap manually

0reactions
ice1000commented, Nov 14, 2021

Fixed already

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - What is a NullPointerException, and how do I fix it?
The NullPointerException (NPE) typically occurs when you declare a variable but did not create an object and assign it to the variable before...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found