[issue23518] Misplaced diagnostic caret for some SyntaxErrors

2015-02-25 Thread Zachary Ware

Zachary Ware added the comment:

The problem is, the interpreter can't know what you meant to do, so it can only 
point out what it can't compile.  We did recently add a special case for print 
without parentheses, but adding special cases for everything is just not 
feasible.  Besides, where should the caret point in each of these cases, why, 
and how would you explain it to the parser?

for x in the range(10):

for x in range(10) the:

for x in range(10) range(10):

for each x in range(10):

for x each in range(10):


Those are just some of the possibilities for just the for statement, let alone 
every other statement, or even every place an expression can be used.

If you can come up with a good, simple, general patch that covers every case, 
please do so!  I'm quite sure it would be accepted.  But until then, I'm afraid 
this isn't going to happen.

--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23518
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23518] Misplaced diagnostic caret for some SyntaxErrors

2015-02-25 Thread Zack Weinberg

Zack Weinberg added the comment:

In terms of the formal grammar of the language, you are correct.  However, the 
position of the caret should be chosen based *not* on the formal grammar, but 
on a heuristic estimation of what the most probable mistake actually is.  In 
both of the cases I listed, the most probable mistake is as I described.  
Please reconsider.

--
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23518
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23518] Misplaced diagnostic caret for some SyntaxErrors

2015-02-24 Thread Zack Weinberg

New submission from Zack Weinberg:

I tripped over a couple of SyntaxError cases where the diagnostic caret is 
misplaced.

 While x:
  File stdin, line 1
While x:
  ^
SyntaxError: invalid syntax

The caret should point to the capital W in 'While'.

 for x in the range(10):
  File stdin, line 1
for x in the range(10):
 ^
SyntaxError: invalid syntax

The caret should point to the 'the'.

--
messages: 236560
nosy: zwol
priority: normal
severity: normal
status: open
title: Misplaced diagnostic caret for some SyntaxErrors

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23518
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com