FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-42128: Add 'missing :' syntax error message to match statements by pablogsal · Pull Request #24733 · python/cpython · GitHub

/ cpython Public

bpo-42128: Add 'missing :' syntax error message to match statements - #24733

Merged
pablogsal merged 2 commits into
python:masterfrom
pablogsal:match-colon
Mar 18, 2021
Merged

bpo-42128: Add 'missing :' syntax error message to match statements#24733
pablogsal merged 2 commits into
python:masterfrom
pablogsal:match-colon

Conversation

pablogsal commented Mar 3, 2021
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is this safe? While match x is invalid, match (x) should be a function call.

Copy link
Copy Markdown
Member Author

Is this safe? While match x is invalid, match (x) should be a function call.

Hummmm, that's a good point. if match(x) is by itself this will probably fail. Let me think how can we workaround that

Copy link
Copy Markdown
Member Author

I will add also a test for that case

Copy link
Copy Markdown
Member Author

Fixed in the last ammend

brandtbucher commented Mar 3, 2021
edited
Loading

Copy link
Copy Markdown
Member

For my own understanding... does double-ampersand raise a SyntaxError at that token's location suggesting it if it doesn't exist? That's really nice.

Copy link
Copy Markdown
Member Author

For my own understanding... does double-ampersand raise a SyntaxError at that token's location suggesting it if it doesn't exist? That's really nice.

Yeah, is a "forced token" operator. Notice that it also hard-stops the parsing: no other alternative will be considered.

pablogsal requested a review from gvanrossum March 3, 2021 21:30

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't understand why e.g. match(1) doesn't reach invalid_match_stmt, so I'm still concerned.

pablogsal commented Mar 4, 2021
edited
Loading

Copy link
Copy Markdown
Member Author

I don't understand why e.g. match(1) doesn't reach invalid_match_stmt, so I'm still concerned.

The invalid_* rules are now only checked in a second pass of the parser if the first one fails. This was done mainly for speed, but allows to introduce these kind of error messages with early failures.

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ehh! I totally forgot about that!

brandtbucher commented Mar 4, 2021
edited
Loading

Copy link
Copy Markdown
Member

Does invalid_match still need to be guarded with CHECK_VERSION?

Copy link
Copy Markdown
Member Author

Does invalid_match still need to be guarded with CHECK_VERSION?

Not really because is a syntax error, but it certainly won't hurt.

brandtbucher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks!

pablogsal merged commit 08fb8ac into python:master Mar 18, 2021
pablogsal deleted the match-colon branch March 18, 2021 01:03
jab added a commit to jab/cpython that referenced this pull request Mar 20, 2021
* master: (129 commits)
  bpo-43452: Micro-optimizations to PyType_Lookup (pythonGH-24804)
  bpo-43517: Fix false positive in detection of circular imports (python#24895)
  bpo-43494: Make some minor changes to lnotab notes (pythonGH-24861)
  Mention that code.co_lnotab is deprecated in what's new for 3.10. (python#24902)
  bpo-43244: Remove symtable.h header file (pythonGH-24910)
  bpo-43466: Add --with-openssl-rpath configure option (pythonGH-24820)
  Fix a typo in c-analyzer (pythonGH-24468)
  bpo-41561: Add workaround for Ubuntu's custom security level (pythonGH-24915)
  bpo-43521: Allow ast.unparse with empty sets and NaN (pythonGH-24897)
  bpo-43244: Remove the PyAST_Validate() function (pythonGH-24911)
  bpo-43541: Fix PyEval_EvalCodeEx() regression (pythonGH-24918)
  bpo-43244: Fix test_peg_generators on Windows (pythonGH-24913)
  bpo-39342: Expose X509_V_FLAG_ALLOW_PROXY_CERTS in ssl module (pythonGH-18011)
  bpo-43244: Fix test_peg_generator for PyAST_Validate() (pythonGH-24912)
  bpo-42128: Add 'missing :' syntax error message to match statements (pythonGH-24733)
  bpo-43244: Add pycore_ast.h header file (pythonGH-24908)
  bpo-43244: Rename pycore_ast.h to pycore_ast_state.h (pythonGH-24907)
  Remove unnecessary imports in the grammar parser (pythonGH-24904)
  bpo-35883: Py_DecodeLocale() escapes invalid Unicode characters (pythonGH-24843)
  Add PEP 626 to what's new in 3.10. (python#24892)
  ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL