ceylon / ceylon.ast

Apache License 2.0
18 stars 3 forks source link

Bug with PatternParameter while parsing with parseCompilationUnit #148

Open Podmev opened 6 years ago

Podmev commented 6 years ago

AssertError is thrown while parsing valid compiling code:

import ceylon.ast.redhat {
    parseCompilationUnit
}
shared void foo() {
    print({ "1"->"2" }.filter((a->b) => true));
}

String fooLiteral =
        """shared void foo() {
                 print({ "1"->"2" }.filter((a->b) => true));
           }
           """;

shared void fooParse(){
    print(parseCompilationUnit(fooLiteral));
}

Stack trace:

Exception in thread "main" ceylon.language.AssertionError "Assertion failed
    violated is JParameterDeclaration|JInitializerParameter parameter
        expression has class com.redhat.ceylon.compiler.typechecker.tree::Tree.PatternParameter which is not a subtype of com.redhat.ceylon.compiler.typechecker.tree::Tree.ParameterDeclaration|com.redhat.ceylon.compiler.typechecker.tree::Tree.InitializerParameter"
    at ceylon.ast.redhat.parameterToCeylon_.parameterToCeylon(Parameter.ceylon:21)
    at ceylon.ast.redhat.parametersToCeylon_$1.$call$(Parameters.ceylon)
    at ceylon.ast.redhat.parametersToCeylon_$1.$call$(Parameters.ceylon:17)
    at ceylon.ast.redhat.propagateUpdate_$1.$call$(propagateUpdate.ceylon:16)
    at ceylon.ast.redhat.propagateUpdate_$1.$call$(propagateUpdate.ceylon:16)
    at ceylon.language.Iterable$impl$3$1.next(Iterable.ceylon:400)
    at com.redhat.ceylon.compiler.java.language.ConstantIterable$1.next(ConstantIterable.java:51)
    at ceylon.language.Array.createArrayFromIterable(Array.java:164)
    at ceylon.language.Array.<init>(Array.java:112)
    at ceylon.language.Iterable$impl.sequence(Iterable.ceylon:286)
    at ceylon.language.impl.BaseIterable.sequence(bases.ceylon)
    ...