`__guard case` on a field of a `TrivialRegisterPassable` value fails with "operand #0 does not dominate this use"
Les mainteneurs répondent en général sous 2 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 42/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Domaine
- compilers
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Mojo
- Étoiles
- 30.2k
- Forks
- 3.2k
- Merge moyen
- 6 j 20 h
- PR mergées (30 j)
- 25
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modular/modular
-
bug_feature_triaged Team: Mojo Libraries
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 2 jours
-
[BUG]Incomplete Apache LicenseOuvertebug bug_feature_triaged documentation mojo
Difficulté 1/5 Moins d'une heure Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 2 jours
-
`Counter.lt()` and `Counter.gt()` disagree with `__eq__`, and `a.lt(a)` can be `True`Peut-être pris @YidaWeng l’a pris il y a 2 jours. Ouvertebug_feature_triaged Team: Mojo Libraries
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
modular/modular#7696 · 2 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
[BUG] `Counter` `-=`, `+=` and `&=` leave keys behind when they remove many keysPeut-être pris @Tharun-Kumar-McW l’a pris il y a 5 jours. Ouvertebug bug_feature_triaged mojo-stdlib Team: Mojo Libraries
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
modular/modular#7658 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
[BUG] exp(NaN) returns infOuvertebug bug_feature_triaged mojo Team: Mojo Libraries
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
modular/modular#7646 · 3 commentaires ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de modular/modular
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
sagemathinc/sagebrush#1683 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
baseballyama/rsvelte#5235 ·
Les mainteneurs répondent en général sous 1 jour
-
lang-core: member access on a component instance reads its internal fields instead of giving nullOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
midspiral/LemmaScript#355 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour