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

A simple inline comment crashes compiler with NPE #11276

Closed
hubertp opened this issue Oct 8, 2024 · 1 comment · Fixed by #11333
Closed

A simple inline comment crashes compiler with NPE #11276

hubertp opened this issue Oct 8, 2024 · 1 comment · Fixed by #11333
Assignees

Comments

@hubertp
Copy link
Collaborator

hubertp commented Oct 8, 2024

main args =
    v = 42 ## meh
    v

will blow up:

> ./built-distribution/enso-engine-0.0.0-dev-linux-amd64/enso-0.0.0-dev/bin/enso --run simple-crash.enso

[ERROR] [enso.org.enso.compiler.Compiler] Encountered a critical failure while parsing module
java.lang.NullPointerException: Cannot invoke "org.enso.compiler.core.ir.Expression.transformExpressions(scala.PartialFunction)" because "x$1" is null
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression.$anonfun$transformExpressions$1(Expression.scala:24)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.CallArgument$Specified.mapExpressions(CallArgument.scala:124)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.CallArgument$Specified.mapExpressions(CallArgument.scala:43)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.expression.Application$Prefix.$anonfun$mapExpressions$1(Application.scala:144)
	at [email protected]/scala.collection.immutable.List.map(List.scala:246)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.expression.Application$Prefix.mapExpressions(Application.scala:144)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.expression.Application$Prefix.mapExpressions(Application.scala:24)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression.transformExpressions(Expression.scala:24)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression.transformExpressions$(Expression.scala:18)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.expression.Application$Prefix.transformExpressions(Application.scala:24)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression.$anonfun$transformExpressions$1(Expression.scala:24)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression$Binding.mapExpressions(Expression.scala:280)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression$Binding.mapExpressions(Expression.scala:192)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression.transformExpressions(Expression.scala:24)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression.transformExpressions$(Expression.scala:18)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression$Binding.transformExpressions(Expression.scala:192)
	at org.enso.runtime.compiler/org.enso.compiler.pass.resolve.DocumentationComments$.org$enso$compiler$pass$resolve$DocumentationComments$$resolveExpression(DocumentationComments.scala:83)
	at org.enso.runtime.compiler/org.enso.compiler.pass.resolve.DocumentationComments$$anonfun$org$enso$compiler$pass$resolve$DocumentationComments$$resolveExpression$1.$anonfun$applyOrElse$1(DocumentationComments.scala:86)
	at [email protected]/scala.collection.immutable.List.map(List.scala:246)
	at org.enso.runtime.compiler/org.enso.compiler.pass.resolve.DocumentationComments$$anonfun$org$enso$compiler$pass$resolve$DocumentationComments$$resolveExpression$1.applyOrElse(DocumentationComments.scala:86)
	at org.enso.runtime.compiler/org.enso.compiler.pass.resolve.DocumentationComments$$anonfun$org$enso$compiler$pass$resolve$DocumentationComments$$resolveExpression$1.applyOrElse(DocumentationComments.scala:83)
	at [email protected]/scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:35)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression.transformExpressions(Expression.scala:22)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression.transformExpressions$(Expression.scala:18)
	at org.enso.runtime.parser/org.enso.compiler.core.ir.Expression$Block.transformExpressions(Expression.scala:57)
	at org.enso.runtime.compiler/org.enso.compiler.pass.resolve.DocumentationComments$.org$enso$compiler$pass$resolve$DocumentationComments$$resolveExpression(DocumentationComments.scala:83)
	at org.enso.runtime.compiler/org.enso.compiler.pass.resolve.DocumentationComments$.resolveDefinition(DocumentationComments.scala:167)
	at org.enso.runtime.compiler/org.enso.compiler.pass.resolve.DocumentationComments$.$anonfun$resolveModule$5(DocumentationComments.scala:211)
	at [email protected]/scala.collection.immutable.List.map(List.scala:246)
...
@kazcw
Copy link
Contributor

kazcw commented Oct 8, 2024

The AST looks reasonable:

> echo -en 'foo ## bar\nbaz' | cargo run -p enso-parser-debug --bin enso-parser-debug
(BodyBlock #(
 (App (Ident foo) (Documented (#((Section " bar")) #()) ()))
 (Ident baz)))

A syntax warning would be nice, since documentation at the end of a line is not supported (the documentation could be associated with the preceding content, but this is not a planned feature AFAIK); I added this to a (new) syntax-warning wishlist issue.

@JaroslavTulach JaroslavTulach changed the title A simple inline comment crashes compiler A simple inline comment crashes compiler with NPE Oct 15, 2024
@JaroslavTulach JaroslavTulach linked a pull request Oct 16, 2024 that will close this issue
5 tasks
@github-project-automation github-project-automation bot moved this from 🔧 Implementation to 🟢 Accepted in Issues Board Oct 16, 2024
@kazcw kazcw self-assigned this Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🟢 Accepted
Development

Successfully merging a pull request may close this issue.

3 participants