Title: SyntaxError rather than NameError
Type: behavior Stage: resolved
Components: Build Versions:
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith,, ronaldoussoren, wyz23x2
Priority: normal Keywords:

Created on 2020-07-25 11:58 by, last changed 2020-07-25 13:49 by eric.smith. This issue is now closed.

Messages (4)
msg374252 - (view) Author: Philip R Brenan ( Date: 2020-07-25 11:58
a = false

# Traceback (most recent call last):
#   File "", line 1, in <module>
#     a = false
# NameError: name 'false' is not defined
# Compilation finished successfully.

Please make this a syntax error rather than a run time error as the user intention is obvious and there cannot possibly be a variable called 'false' yet.
msg374254 - (view) Author: wyz23x2 (wyz23x2) * Date: 2020-07-25 12:21
There is nothing *wrong* with the syntax; it's just a regular assignment.
It's not something like `False = 4` or `while = 6` which '=' is invalid.
msg374257 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-07-25 12:30
The compiler cannot know if "false" is an existing name when compiling. 

One example is that the name might refer to the name of a builtin.
msg374268 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-07-25 13:49
As an example of why it's not possible for the compiler to treat this as a syntax error: I use python for my config files. Before I load these files, I inject names into the builtins, so that the config files can reference them. Some of these are constants, others are callbacks. "false" or anything else could be one of the injected names.
Date User Action Args
2020-07-25 13:49:41eric.smithsetnosy: + eric.smith
messages: + msg374268
2020-07-25 12:30:25ronaldoussorensetstatus: open -> closed

type: compile error -> behavior

nosy: + ronaldoussoren
messages: + msg374257
resolution: not a bug
stage: resolved
2020-07-25 12:21:38wyz23x2settitle: SyntaxError rather than NameError error -> SyntaxError rather than NameError
2020-07-25 12:21:28wyz23x2setnosy: + wyz23x2

messages: + msg374254
title: Syntax error rather than run time error -> SyntaxError rather than NameError error
2020-07-25 11:58:35philiprbrenan@gmail.comcreate