Expected 'end' message not the most helpful in throw function

The proposed error is actually impossible because throw is not a reserved keyword, just a name in the module Core. For example, this is valid:

julia> let throw = 1
         throw + 2
       end
3

So the parser actually has no idea what throw does, let alone that it must be a callable function. This is generally true for languages with assignments and function definitions in namespaces.

The one exception I know is Python 3's print function, and that's a special case because Python 2 reserved a leading spaced keyword for it; otherwise, spaced out names just get a generic syntax error. That error becomes misleading in scopes where print gets reassigned (expand for example).
>>> print = 1
>>> print 2
  File "<python-input-1>", line 1
    print 2
    ^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
>>> print(2)
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    print(2)
    ~~~~~^^^
TypeError: 'int' object is not callable
>>> print + 2
3
3 Likes