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
}
        SBlock userBlockNode = userLambdaNode.getBlockNode();
        if (userBlockNode.getStatementNodes().isEmpty()) {
            throw userLambdaNode.createError(new IllegalArgumentException("cannot generate empty lambda"));
        }
        semanticScope.setCondition(userBlockNode, LastSource.class);
        visit(userBlockNode, lambdaScope);
        if (lambdaScope.usesInstanceMethod()) {
            semanticScope.setCondition(userLambdaNode, InstanceCapturingLambda.class);
        }
        if (semanticScope.getCondition(userBlockNode, MethodEscape.class) == false) {
            throw userLambdaNode.createError(new IllegalArgumentException("not all paths return a value for lambda"));
        }
        
        List<Variable> capturedVariables = new ArrayList<>(lambdaScope.getCaptures());
        List<Class<?>> typeParametersWithCaptures = new ArrayList<>(capturedVariables.size() + typeParameters.size());
        List<String> parameterNamesWithCaptures = new ArrayList<>(capturedVariables.size() + parameterNames.size());
        for (Variable capturedVariable : capturedVariables) {
            typeParametersWithCaptures.add(capturedVariable.type());
            parameterNamesWithCaptures.add(capturedVariable.name());
        }
        typeParametersWithCaptures.addAll(typeParameters);
        parameterNamesWithCaptures.addAll(parameterNames);
        
        String name = scriptScope.getNextSyntheticName("lambda");
        boolean isStatic = lambdaScope.usesInstanceMethod() == false;
        scriptScope.getFunctionTable().addFunction(name, returnType, typeParametersWithCaptures, true, isStatic);
        Class<?> valueType;
        
        if (targetType == null) {