Skip to content

static final null character crashes parser #21357

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

Closed
mebur opened this issue Aug 9, 2024 · 1 comment
Closed

static final null character crashes parser #21357

mebur opened this issue Aug 9, 2024 · 1 comment

Comments

@mebur
Copy link

mebur commented Aug 9, 2024

Compiler version

3.3.3

Minimized code

(Java class)

public class Test {
static final char NULL = '\u0000';
}

Output

exception occurred while parser Test.java

An unhandled exception was thrown in the compiler.
Please file a crash report here:
https://github.com/lampepfl/dotty/issues/new/choose

 while compiling: Test.java
    during phase: parser
            mode: Mode(ImplicitsEnabled)
 library version: version 2.13.12
compiler version: version 3.3.3
        settings:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.lang.String.checkIndex(String.java:4832)
at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:46)
at java.base/java.lang.String.charAt(String.java:1555)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.tryConstant(JavaParsers.scala:1034)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.optConstantTpe$1(JavaParsers.scala:726)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.varDecl(JavaParsers.scala:733)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.fieldDecls(JavaParsers.scala:665)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.termDecl(JavaParsers.scala:647)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.memberDecl(JavaParsers.scala:747)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.typeBodyDecls(JavaParsers.scala:918)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.typeBody(JavaParsers.scala:897)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.classDecl(JavaParsers.scala:822)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.typeDecl(JavaParsers.scala:1022)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.compilationUnit(JavaParsers.scala:1076)
at dotty.tools.dotc.parsing.JavaParsers$JavaParser.parse(JavaParsers.scala:44)
at dotty.tools.dotc.parsing.Parser.parse$$anonfun$1(ParserPhase.scala:28)
at dotty.tools.dotc.parsing.Parser.parse$$anonfun$adapted$1(ParserPhase.scala:40)
at scala.Function0.apply$mcV$sp(Function0.scala:42)
at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:440)
at dotty.tools.dotc.parsing.Parser.parse(ParserPhase.scala:40)
at dotty.tools.dotc.parsing.Parser.runOn$$anonfun$1(ParserPhase.scala:49)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:333)
at dotty.tools.dotc.parsing.Parser.runOn(ParserPhase.scala:49)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:246)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:262)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:270)
at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:279)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:71)
at dotty.tools.dotc.Run.compileUnits(Run.scala:279)
at dotty.tools.dotc.Run.compileSources(Run.scala:194)
at dotty.tools.dotc.Run.compile(Run.scala:179)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
at dotty.tools.dotc.Driver.process(Driver.scala:197)
at dotty.tools.dotc.Driver.process(Driver.scala:165)
at dotty.tools.dotc.Driver.process(Driver.scala:177)
at dotty.tools.dotc.Driver.main(Driver.scala:207)
at dotty.tools.MainGenericCompiler$.run$1(MainGenericCompiler.scala:162)
at dotty.tools.MainGenericCompiler$.main(MainGenericCompiler.scala:186)
at dotty.tools.MainGenericCompiler.main(MainGenericCompiler.scala)

Expectation

Should compile without a problem, it only occurs when it's both static and final.

@mebur mebur added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 9, 2024
@som-snytt
Copy link
Contributor

Duplicates #18490 fixed on 3.4

@som-snytt som-snytt closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2024
@som-snytt som-snytt added stat:duplicate and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants