`__guard case` on a field of a `TrivialRegisterPassable` value fails with "operand #0 does not dominate this use"
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- compilers
Línea de trabajo
Start by running the supplied mojo run repro.mojo example and inspect the compiler pass that handles multi-clause __guard bindings. Trace how a temporary matched by a later case clause is kept alive when its binding is used after the guard. Done means the example compiles and prints 3 -1 -1.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
EDIT: Main already has a fix for the multi-clause case that this issue first reported (below the line). The fix is not in 1.3.0.dev2026112105 or earlier nightlies. This issue now tracks a related case that still fails on main.
A __guard case fails in the pass manager when all of these are true:
- The subject is a field of a
TrivialRegisterPassablevalue. - The pattern binds by reference.
- The code uses the binding after the guard.
from std.collections import OptionalReg
@fieldwise_init
struct Holder(TrivialRegisterPassable):
var opt: OptionalReg[Int]
def get(h: Holder) -> Int:
__guard case .Some(x) = h.opt else:
return -1
return x
def main():
print(get(Holder(OptionalReg[Int](3))), get(Holder(OptionalReg[Int]())))
mojo run repro.mojo:
repro.mojo:12:12: error: operand #0 does not dominate this use
return x
^
repro.mojo:10:24: note: operand defined here (op in a child region)
__guard case .Some(x) = h.opt else:
^
mojo: error: failed to run the pass manager
Expected: prints 3 -1.
Each of these changes makes the program compile and print 3 -1:
- Bind by value:
case .Some(var x). - Declare
HolderasCopyable, Movable. - Copy
h.optto a local variable before the guard.
A method of a register-passable struct fails in the same way on self.field. All the builds that we tried fail, from the 1.3.0.dev2026111605 nightly to main.
ORIGINAL TITLE: Multi-clause __guard: a later case clause on a temporary fails with "operand #0 does not dominate this use"
A multi-clause __guard fails in the pass manager in one specific case. It needs a case clause that follows an earlier case clause, matches a temporary, binds by reference, and has its binding used after the guard.
def maybe(v: Int) -> Optional[Int]:
return Optional(v) if v >= 0 else None
def f(a: Optional[Int]) -> Int:
__guard case .Some(x) = a; case .Some(y) = maybe(x) else:
return -1
return y
def main():
print(f(Optional(3)), f(None), f(Optional(-2)))
mojo run repro.mojo:
repro.mojo:8:12: error: operand #0 does not dominate this use
return y
^
repro.mojo:8:12: note: see current operation: "pop.stack_alloc.lifetime.end"(%18) : (!kgen.pointer<struct<(struct<(variant<struct<()>, struct<(struct<(scalar<index>) isParamPack>)>>)>)>>) -> ()
repro.mojo:6:53: note: operand defined here (op in a child region)
__guard case .Some(x) = a; case .Some(y) = maybe(x) else:
^
mojo: error: failed to run the pass manager
Expected: prints 3 -1 -1.
- Lenguaje dominante
- Mojo
- Estrellas
- 30.2k
- Forks
- 3.2k
- Merge medio
- 6 d 20 h
- PR fusionados (30 d)
- 25
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modular/modular
-
bug_feature_triaged Team: Mojo Libraries
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
[BUG]Incomplete Apache LicenseAbiertobug bug_feature_triaged documentation mojo
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
Los mantenedores suelen responder en 2 días
-
`Counter.lt()` and `Counter.gt()` disagree with `__eq__`, and `a.lt(a)` can be `True`Posiblemente ocupada @YidaWeng la tomó hace 2 días. Abiertobug_feature_triaged Team: Mojo Libraries
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
modular/modular#7696 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
[BUG] `Counter` `-=`, `+=` and `&=` leave keys behind when they remove many keysPosiblemente ocupada @Tharun-Kumar-McW la tomó hace 5 días. Abiertobug bug_feature_triaged mojo-stdlib Team: Mojo Libraries
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
modular/modular#7658 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
[BUG] exp(NaN) returns infAbiertobug bug_feature_triaged mojo Team: Mojo Libraries
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
modular/modular#7646 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de modular/modular
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
sagemathinc/sagebrush#1683 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
baseballyama/rsvelte#5235 ·
Los mantenedores suelen responder en 1 día
-
lang-core: member access on a component instance reads its internal fields instead of giving nullAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
midspiral/LemmaScript#355 · 1 comentario ·
Los mantenedores suelen responder en 1 día