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

Compiler crash on `new S { }` where `S` is a struct

Aperta Adatta ai principianti
#13,610 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à
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Ambito
compilers

Direzione di ricerca

Inizia in Resolver.scala, vicino a resolveAmbiguousNewAsObject (l’issue indica le righe 1722–1730) e segui come il suo ramo struct registra gli errori. Riproduci il problema con il programma Flix minimo dell’issue, poi controlla il caso esistente NewStructWithObjectMethods per verificare il comportamento di errore previsto. Il lavoro è concluso quando il compilatore segnala un errore di risoluzione per new E { } e non va più in crash in TreeShaker1.

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

Descrizione

bug

Minimal example:

struct E[r] { }

def main(): Unit \ IO = region rc {
    let _ = new E { };
    println("hello")
}

Actual: the frontend reports no errors and the backend crashes:

# An unexpected error has been detected by the Flix compiler:
#
#   Unexpected error expression near (crash.flix:4:13)
#
ca.uwaterloo.flix.util.InternalCompilerException: Unexpected error expression near (crash.flix:4:13)
	at ca.uwaterloo.flix.language.phase.TreeShaker1$.visitExp(TreeShaker1.scala:316)
	at ca.uwaterloo.flix.language.phase.TreeShaker1$.visitExp(TreeShaker1.scala:142)
	at ca.uwaterloo.flix.language.phase.TreeShaker1$.visitSym(TreeShaker1.scala:58)

Flix 0.79.0, master at f45cd5a4e.

Expected: a resolution error. Either NewStructWithObjectMethods as today for new E { def m() = ... }, or better a dedicated error saying that a struct new needs an @ region.

Cause: new E { } has neither a region nor fields, so Resolver treats it as object-shaped and calls resolveAmbiguousNewAsObject. When the name resolves to a struct, that function only adds an error to sctx.errors if constructors.nonEmpty or methods.nonEmpty, but it unconditionally returns ResolvedAst.Expr.Error(primaryErr) (Resolver.scala:1722-1730). With both lists empty no error is ever registered, the frontend reports success, and TreeShaker1 throws on the leftover Expr.Error node.

Fix: always register the primary error in that branch (or emit the dedicated error mentioned above).

Found while exploring #13609.

Lingua principale
Flix
Stelle
2.7k
Fork
194
Merge medio
8h 15m
PR unite (30g)
131

Preparare l'ambiente

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 flix/flix

Tutte le issue di flix/flix

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.