Ruby scripts with 'nil'?

I am trying to use nil in a script field, but I get an error

GroovyScriptExecutionException[MissingPropertyException[No such property: nil for class: b5366a2d2ac98dae978423083f8b09e5cddc705d]]

Here is a demonstration script.

{
  "query": {
    "match_all": {}
  },
  "script_fields": {
    "test": {
      "script": "nil"
    }
  },
  "size": 10
}

Really, any script with nil will return this error (also scripts with begin and end also fail)

What type of Ruby is Elasticsearch using as a scripting language? Must I import nil first? How do I do use nil in a script?

Thanks

PS: For the pedantic, my real script is trying to get the length of a string:

doc["name"].empty ? nil : doc["name"].value.length()

Judging by the first word of the error message it's a Groovy script, in which case "null" is what you're looking for.