I got an unexpected internal NPE when playing with this script.

```
POST _scripts/painless/_execute
{
  "script": {
    "source": """
    return /[^\w]+/.split('abc   def higkln').toArray(String[]::new)
    """
  }
}
```
```
{
  "error" : {
    "root_cause" : [
      {
        "type" : "script_exception",
        "reason" : "compile error",
        "script_stack" : [ ],
        "script" : "\n    return /[^\\w]+/.split('abc   def higkln').toArray(String[]::new)\n    ",
        "lang" : "painless"
      }
    ],
    "type" : "script_exception",
    "reason" : "compile error",
    "script_stack" : [ ],
    "script" : "\n    return /[^\\w]+/.split('abc   def higkln').toArray(String[]::new)\n    ",
    "lang" : "painless",
    "caused_by" : {
      "type" : "null_pointer_exception",
      "reason" : "Cannot read field \"annotations\" because the return value of \"org.elasticsearch.painless.lookup.PainlessLookup.lookupPainlessClass(java.lang.Class)\" is null"
    }
  },
  "status" : 400
}

```
modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultSemanticAnalysisPhase.java
);
            }
            SemanticScope.Variable captured = semanticScope.getVariable(location, symbol);
            semanticScope.putDecoration(userFunctionRefNode, new CapturesDecoration(List.of(captured)));
            if (captured.type().isPrimitive()) {
                semanticScope.setCondition(userFunctionRefNode, CaptureBox.class);
            }
            if (targetType == null) {
                EncodingDecoration encodingDecoration;
                if (captured.type() == def.class) {
                    
                    encodingDecoration = EncodingDecoration.of(false, false, symbol, methodName, 1);
                } else {
                    
                    encodingDecoration = EncodingDecoration.of(true, false, captured.getCanonicalTypeName(), methodName, 1);
                }
                valueType = String.class;
                semanticScope.putDecoration(userFunctionRefNode, encodingDecoration);
            } else {
                valueType = targetType.targetType();
                
                if (captured.type() != def.class) {
                    FunctionRef ref = FunctionRef.create(
                        scriptScope.getPainlessLookup(),
                        scriptScope.getFunctionTable(),
                        location,
                        targetType.targetType(),
                        captured.getCanonicalTypeName(),
                        methodName,
                        1,