"Operands must be numbers" should not be thrown for `string + null`

An example program like this:

fun greet(name: string, age: int): void {
  print "Hello " + name + ". Your age is " + age;
}

// Expected warning: [line 6] Warning at 'name': Null parameter detected
greet(null, 42);

...will currently cause the following error to be logged:

[line 2] Operands must be numbers, not string and null

This is problematic for a couple of reasons:

  1. Not only numbers are in fact accepted by the + operator. string + string is fine; string + null is not.
  2. The error implies that this is a compilation error. We should more clearly make it be apparent that this is a runtime error.

Even better, if we have the energy, would be to do compile-time analysis of the code above and emit a validation error. Either way is fine, but we should at the very least try to avoid an outright misleading error message like we currently produce.

Assignee Loading
Time tracking Loading