Illegal "yield (from)" python syntax accepted
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia riproducendo l'esempio yield from dell'issue e traccia il modo in cui il parser gestisce l'espressione. Il lavoro è completato quando la sintassi Python non valida segnalata da Ruff viene rifiutata, invece di essere trattata come codice valido o di produrre un autofix che introduce un errore di sintassi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Originally reported as https://github.com/astral-sh/ruff/issues/4992.
I'm not quite sure where the incorrectness here is, but I think this bug indicates an incorrect parsing of the
yield fromexpression. The following is a python snippet with illegal syntax:def e(): x = yield from y = 5We can verify that it is indeed illegal syntax with:
$ python yield-elision.py File "/tmp/tmp.1z4PScoI6T/yield-elision.py", line 2 x = yield from y = 5 ^^^^^^^^^^^^ SyntaxError: assignment to yield expression not possibleRuff, however, believes this is valid syntax:
$ ruff yield-elision.py --show-source --show-fixes yield-elision.py:2:3: F841 [*] Local variable `x` is assigned to but never used | 2 | def e(): 3 | x = yield from y = 5 | ^ F841 | = help: Remove assignment to unused variable `x` yield-elision.py:2:18: F821 Undefined name `y` | 2 | def e(): 3 | x = yield from y = 5 | ^ F821 | Found 2 errors.And will attempt to fix it, leading to a self-reported parsing error:
$ ruff yield-elision.py --fix error: Autofix introduced a syntax error in `yield-elision.py` with rule codes F841: invalid syntax. Got unexpected token '=' at byte offset 24 --- def e(): yield from y = 5 --- yield-elision.py:2:3: F841 Local variable `x` is assigned to but never used yield-elision.py:2:18: F821 Undefined name `y` Found 2 errors.I believe this indicates a parsing bug.
- Lingua principale
- Rust
- Stelle
- 117
- Fork
- 38
- Merge medio
- 4g 7h
- PR unite (30g)
- 1
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RustPython/Parser
-
Maintenance status Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 25/100
RustPython/Parser#140 · 3 commenti ·
-
`unic` is unmaintained Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
RustPython/Parser#139 · 3 commenti ·
-
cargo audit paste Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
RustPython/Parser#137 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 50/100
RustPython/Parser#133 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
RustPython/Parser#130 ·
Tutte le issue di RustPython/Parser
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
MystenLabs/sui#28056 · 1 commento ·
-
type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Luminous-Dynamics/mycelix#2577 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
registrystack/registry-stack#1239 ·
-
package-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
msys2/MINGW-packages#31806 ·