A single pattern like c is >= ' ' and <= '~' reads as one compact idea: is this a printable ASCII character. But there is no "and" instruction in the CLR, no "relational pattern" opcode, nothing in the metadata that records a combinator. By the time the compiler is finished, that line is a pair of integer comparisons and two conditional branches that both jump to the same place on failure. Reading compiled code, you do not see a combinator tree — you see a short forest of blt/bgt/beq that happens to spell one out. Folding that forest back into and, or, and not is a precise exercise in grouping branches by where they go.
The real question
Relational and logical patterns are syntactic sugar over ordinary comparisons. Every opcode in their lowering is a plain blt.s, bgt.s, beq.s, or brfalse.s — nothing exotic to decode. So the question Glass answers is never what does this instruction mean. It is does this cluster of compares and branches reconstitute a combinator pattern — and if so, which parts are joined by and, which by or, and where not flipped the sense. That is a structural question about branch targets, not a one-instruction lookup.
A combinator pattern, lowered
Start with the printable-ASCII test — an and of two relational patterns:
public static bool IsPrintable(char c) => c is >= ' ' and <= '~'; Both halves must hold. The compiler emits them as two comparisons that short-circuit to a shared failure on the first that breaks:
.method public hidebysig static bool IsPrintable(char c) cil managed { ldarg.0 ldc.i4.s 32 // ' ' blt.s FAIL // c >= ' ' (fail if below) ldarg.0 ldc.i4.s 126 // '~' bgt.s FAIL // c <= '~' (fail if above) ldc.i4.1 ret FAIL: ldc.i4.0 ret } The shape of an and is right there in the branch targets: every subpattern jumps to the same failure label, and the success path is the fall-through past all of them. Both blt.s and bgt.s target FAIL; you only load 1 by surviving both.
Now the mirror image — an or of constant patterns:
public static bool IsVowel(char c) => c is 'a' or 'e' or 'i' or 'o' or 'u'; Here any one match is enough, so the branches invert: each subpattern jumps to a shared success, and failure is the fall-through past all of them.
ldarg.0 ldc.i4.s 97 // 'a' beq.s PASS ldarg.0 ldc.i4.s 101 // 'e' beq.s PASS ldarg.0 ldc.i4.s 105 // 'i' beq.s PASS // … 'o', 'u' … ldc.i4.0 ret PASS: ldc.i4.1 ret The two combinators are duals: and is a run of branches to a common failure join, or is a run of branches to a common success join. That single distinction — which join do the branches share — is the hinge Glass turns on.
Where not goes
not has no instruction of its own either. It inverts the sense of the branch it guards. c is not '\0' becomes a single beq.s PASS/fall-through flip of the equality test, and obj is not null becomes brfalse/brtrue chosen so the null case lands on the failure side. Because not binds tighter than and, which binds tighter than or, Glass applies inversion to the innermost comparison first, then groups the and runs, then the or runs — rebuilding the tree in precedence order.
and is a run of branches to a common failure join, or a run to a common success join. Glass groups the conditional branches by target, applies not as an inverted branch first, and rebuilds the not > and > or tree. The float case changes the opcode
Relational patterns over floating-point types are the one place the opcode itself carries information, because of NaN. A relational pattern must be false for NaN — double.NaN is > 0.0 is false — and NaN is unordered, neither greater nor less than anything. So the compiler cannot use the plain bgt; it emits the unordered-aware form so the NaN case falls on the false side:
public static bool IsPositive(double d) => d is > 0.0; ldarg.0 ldc.r8 0.0 bgt.un.s PASS // false for NaN: unordered -> not-greater -> fall through ldc.i4.0 ret PASS: ldc.i4.1 ret The .un suffix here does not mean "unsigned" — on floats it means "unordered compares as true/take-the-branch-appropriately for NaN handling." Glass reads the suffix together with the operand type: an .un compare against an r8/r4 constant is a floating relational pattern, and it recovers > 0.0 with the ordering the suffix implies. Get this wrong and you would print a pattern that matches NaN when the real one rejects it — a semantic change, not a cosmetic one.
How Glass folds the tree back
Glass walks the branch cluster and reconstructs the combinator tree by target grouping:
- Find the joins. Collect the conditional branches over a single tested value and bucket them by destination. A set of branches to one common failure continuation is an
and; a set to one common success continuation is anor. - Decode each leaf. A compare-and-branch against a constant is a relational pattern (
< k,>= k) or, forbeq/bne, a constant pattern (k). The branch sense, possibly inverted, tellsnotfrom plain. - Respect precedence. Resolve
notat the leaves, then foldandruns into conjunctions, then join conjunctions withor. The nesting of the joins reproduces the parenthesization. - Require one exit each. An
andgroup must funnel every failure to the same label and anorgroup every success to the same label. If the branches scatter to different destinations, it was never one combinator pattern — it was separate statements.
When the whole cluster lines up, Glass emits >= ' ' and <= '~' or 'a' or 'e' or …. When it does not, it prints the ordinary branch logic as the if/&&/|| it literally is.
The case it cannot decide
Here is the honest limit, and it is the same one every pattern form hits. These two methods compile to byte-identical IL:
bool A(char c) => c is >= 'a' and <= 'z'; bool B(char c) => c >= 'a' && c <= 'z'; The language defines the first as sugar for the second; there is no metadata to separate them because at the IL level there is nothing to separate. Glass resolves it the only defensible way: it prints the pattern form when the cluster matches the combinator lowering shape exactly — the precise comparison order and the single shared join — and the boolean form otherwise. It never guesses that an ordinary && "was probably" an and pattern. The result recompiles to the same assembly either way; the choice is which reading a human would rather see, and the fallback is the truthful one. Inside a switch expression arm the context is unambiguous and Glass always prints the pattern; in a bare boolean-returning expression, the two are genuinely interchangeable.
Using this when you read code
When Glass shows you x is >= a and < b, read the and as a promise about branch structure: both comparisons funnel failure to one join, and the matched value survives only by passing both. When you see x is p or q or r, the duals hold — any one success short-circuits out. If you are chasing a subtle bug in a numeric guard, check the branch opcodes on floats: a .un suffix is the decompiler telling you the original pattern was NaN-aware, and a hand-written > that forgot NaN would read differently. The recovered combinator is a faithful round-trip of the real control flow, not a guess about intent.
Takeaway
Relational and logical patterns leave no combinator opcode in IL — only a forest of compares and conditional branches, the same instructions you would write by hand. Glass rebuilds the and/or/not tree by grouping those branches on their shared target: a common failure join is a conjunction, a common success join is a disjunction, and an inverted branch is a not. It reads the float .un suffix to keep NaN semantics exact, and it falls back to the literal boolean expression the instant the shape is not a clean combinator. Knowing the combinator is a recognized branch shape rather than a recorded fact is what lets you trust the pattern Glass prints — and know when the expanded && in front of you is the real code.
Glass.NET is a free .NET decompiler with a VS-native Avalonia UI, a headless CLI, and an MCP server. It reads metadata and IL statically and never executes the assembly you open — point it at your own binaries or at third-party dependencies you are auditing or debugging. Grab it at /products/glass.

