Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

f-string interpolation calls `str` by name, so a user binding named `str` changes every f-string

Aperta
#1,322 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

Start in the f-string block of src/lexer.c and inspect the lowering used by the VM, then compare the ouroboros frontend/AOT path. Run the two reproductions with EIGS_JIT_OFF=1 and use tests/test_fstrings.eigs as the regression-test entry point. Done means the global, defined, and function-local str cases produce the specified result or fail loudly, with both lowering paths aligned.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area:runtime-vm bug kind:silent-wrong

The lexer lowers f"a{e}b" to ("a" + (str of (e)) + "b") using an ordinary TOK_IDENT "str" (src/lexer.c, f-string block). That identifier is resolved like any other name at run time. A program that binds str therefore changes, or breaks, every f-string evaluated in that scope. Nothing in the source of the f-string mentions str.

Reproduce (origin/main 94c4c5b, release build)

define str(x) as:
    return "HIJACK"
print of f"<{5}>"

Actual: exit 0, stdout <HIJACK>. Expected: <5> (or a loud error, if rebinding str is to be forbidden).

str is 3
print of f"<{str}>"

Actual: exit 1, Error line 2: cannot call num. The failing call is one the user never wrote.

The first case is a silent wrong answer (PRINCIPLES.md §2). A str local inside a function body does the same thing to every f-string in that function.

Done when

  • f-string interpolation converts values with the builtin conversion no matter what str is bound to in the enclosing scopes (for example, a dedicated opcode or a reserved internal name the user cannot bind). The alternative is a decision, recorded here, that rebinding str is an error.
  • Both programs above print <5> and <3> (or fail loudly at the rebinding, if that is the decision), under the VM and with EIGS_JIT_OFF=1.
  • A regression in tests/test_fstrings.eigs covers a global str, a define str, and a function-local str.
  • The ouroboros frontend/AOT mirror whatever lowering is chosen (it lowers f-strings the same way).

Found while fixing #1244, where the synthetic str token is now marked as having no source span so LSP rename never edits it; this issue is about the runtime meaning of that token.

Lingua principale
C
Stelle
3
Fork
7
Merge medio
4h 15m
PR unite (30g)
106

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di InauguralSystems/EigenScript

Tutte le issue di InauguralSystems/EigenScript

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.