eclipse-archived / ceylon.formatter

A formatter for the Ceylon programming language, written in Ceylon.
Apache License 2.0
14 stars 11 forks source link

NPE formatting a ValueSpecification #109

Closed jvasileff closed 9 years ago

jvasileff commented 9 years ago

I'm not sure exactly whose bug this is, but the symptom appears here.

    value node = ValueSpecification {
        name = LIdentifier("a");
        specifier = Specifier(StringLiteral("""a"""));
    };
    format(node.transform(RedHatTransformer(SimpleTokenFactory())));

results in:

Exception in thread "main" ceylon.language.AssertionError "null value returned from native call not assignable to Object"
    at com.redhat.ceylon.compiler.java.Util.checkNull(Util.java:975)
    at ceylon.formatter.FormattingVisitor.visitSpecifierStatement(FormattingVisitor.ceylon:1778)
    at com.redhat.ceylon.compiler.typechecker.tree.VisitorAdaptor.visit(VisitorAdaptor.java:229)
    at com.redhat.ceylon.compiler.typechecker.tree.Tree$SpecifierStatement.visit(Tree.java:3086)
    at ceylon.formatter.format_.format(format.ceylon:72)
    at ceylon.formatter.format_.format(format.ceylon:68)

Line 1778 of FormattingVisitor.ceylon:

writeSemicolon(fWriter, that.mainEndToken, context);
lucaswerkmeister commented 9 years ago

Hm, perhaps the RedHatTransformer isn’t generating a semicolon here. Let me check…

lucaswerkmeister commented 9 years ago

Yup, semicolon missing. IIRC we’re supposed to have tests for that, I need to check why they didn’t detect this…

lucaswerkmeister commented 9 years ago

Ah, completeCompilationUnit only contains ValueSpecification within named arguments (SpecifiedArgument), and RedHatTransformer.transformSpecifiedArgument handles that internally without using transformValueSpecification.

lucaswerkmeister commented 9 years ago

Should be fixed now.

jvasileff commented 9 years ago

Works great, thanks!