Opened 7 years ago

Closed 7 years ago

#16971 closed defect (duplicate)

Notebook does not complain on assignment to literal

Reported by: gagern Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: notebook Keywords: assignment silent syntax preparse
Cc: Merged in:
Authors: Reviewers: Martin von Gagern
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

In the sage notebook (from Sage 6.2) I can write the following things without seeing an exception:

1 = 2
foo = 1 = 2

On the command line, these correctly complain:

sage: 1 = 2
ValueError: The name "1" is not a valid Python identifier.
sage: foo = 1 = 2
SyntaxError: can't assign to function call

But in the notebook, these apparently get executed, since at the end the variable foo has the value 2. So it seems that the notebook does more than preparse indicates. I see no modification of global literals, but even so silently ignoring such errors seems like pretty bad style. Particular since proffesional mathematicians but novice programmers might tend to place = signs in places we don't expect them to.

Change History (3)

comment:1 follow-up: Changed 7 years ago by nbruin

  • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

Dupe of #11542?

comment:2 in reply to: ↑ 1 Changed 7 years ago by gagern

  • Reviewers set to Martin von Gagern
  • Status changed from needs_review to positive_review

Replying to nbruin:

Dupe of #11542?

Yes, looks that way. Hadn't realized that this affects more than notebook.

comment:3 Changed 7 years ago by vbraun

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.