[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public

Conversation

Copy link
Member

pablogsal commented Mar 18, 2019

Copy link
Member Author

As @serhiy-storchaka suggested, I have moved the default cause of the switch outside so the compiler now emits warnings if there are missing cases. For example:

Python/ast.c: In function ‘validate_expr’:
Python/ast.c:226:5: warning: enumeration value ‘NamedExpr_kind’ not handled in switch [-Wswitch]
     switch (exp->kind) {
     ^~~~~~

Python/ast.c Outdated
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: I prefer the current "default:" case coding style :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

The advantage of having it outside the switch is that the compiler complains about missing cases. Check my previous comment and Serhiy's suggestion in the bpo

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok, I see. It makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

Why not add it to exec_tests or single_tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was afraid that the diff will be very difficult to read because the regenerated exec_results, but it turned out to be very simple. I have added the test to exec_results instead of creating a new extra_validation_snippets.

pablogsal force-pushed the bpo36332 branch 3 times, most recently from 3fd32ec to b71484a Compare March 18, 2019 11:09
# Decorator with generator argument
"@deco(a for a in b)\ndef f(): pass",
# Simple assignment expression
"if a:=1:\n True"
Copy link
Member

Choose a reason for hiding this comment

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

Minimal example: "(a := 1)".

Copy link
Member

vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

pablogsal merged commit 0c9258a into python:master Mar 18, 2019
pablogsal deleted the bpo36332 branch March 18, 2019 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants