I get a NullPointerException in the Stratego runtime when certain NaBL&TS code attempts to analyze an input file.

I have this NaBL&TS code:

namespaces
    AjaxFunction

binding rules
    ModuleDef(_, _, _):
        implicitly defines Function "replace"
        of type ([TypeRef("Int", 0, []), TypeRef("String", 0, [])], Void())

    Call(name, _):
        refers to Function name

type rules
    Call(name, args) :-
        where definition of name : (params-ty, ret-ty)
        and args : args-ty
        and args-ty <is: params-ty
        else error "Type mismatch in call arguments" on args
    
relations
    a-ty <is: e-ty
    where
        a-ty == e-ty

When analyzing this input:

function X()
{
    replace(10, "2");
}

I get a NullPointerException:

Internal error evaluating strategy editor-analyze
    editor_analyze_0_0
    analysis_default_editor_0_0
    analysis_single_default_interface_0_0
    analysis_single_default_3_1
    analysis_single_default_4_1
    analysis_files_spoofax_4_2
    analysis_files_spoofax_5_2
    analysis_spoofax_output_1_0
    map_1_0
    analysis_spoofax_update_file_1_0
    set_only_markers_0_1

org.spoofax.interpreter.core.InterpreterException: Exception during evaluation

Caused by: java.lang.NullPointerException
    at org.strategoxt.imp.runtime.stratego.SetOnlyMarkersPrimitive.call(SetOnlyMarkersPrimitive.java:40)

I’ve attached the stack trace.


However, when I change this:

ModuleDef(_, _, _):
    implicitly defines Function "replace"
    of type ([TypeRef("Int", 0, []), TypeRef("String", 0, [])], Void())

to this:

ModuleDef(_, _, _):
    implicitly defines Function "replace"
    of type ([TypeRef("Int", 0, []), TypeRef("String", 0, [])], ())

then the exception doesn’t occur. Note that Void() is a valid constructor defined in my syntax.

Submitted by D. Pelsmaeker on 23 July 2014 at 15:28
Tasks.txt23 July 2014 at 15:28
Stacktrace.txt23 July 2014 at 15:28

On 24 July 2014 at 12:44 D. Pelsmaeker commented:

Hmm.. After an Eclipse restart the issue has vanished, with no changes to the code. Regardless, the fact that there are situations where SetOnlyMarkersPrimitive.java line 40 can throw a NullPointerException is still a bug.

StrategoAnalysisJob job = ((EditorIOAgent)agent).getJob();
StrategoObserver observer = job.getObserver();       // NullPointerException

On 24 July 2014 at 12:57 Vlad Vergu commented:

This looks like a Spoofax bug and not a Stratego bug. If the issue persists please report it again, in the Spoofax project.


On 24 July 2014 at 12:57 Vlad Vergu closed this issue.

Log in to post comments