1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//! [`OpaqueExpr`] - the escape variant, with pessimal semantics written
//! down before the first consumer exists.
//!
//! # Why an escape variant exists at all
//!
//! The retained-AST contract (P1-5) is deliberately narrow: an AST is
//! retained iff the text parses as one complete TS expression covering
//! the whole content. P1-9 measured the text outside that contract at
//! 11.73% of corpus expression rewrites (re-measured at 12.73% for this
//! task - the record has both runs), and two of its classes can **never**
//! carry an AST: text the nesting guard refuses is never handed to a
//! parser at all, and text oxc rejects has no AST by definition. A total
//! `ExprRef` therefore needs this variant no matter how far the retained
//! contract is later widened - widening only moves inputs from `Opaque`
//! to `Js`, it cannot empty the class.
//!
//! # The pessimal laws (the imported LLVM `undef`/`poison` rule)
//!
//! LLVM's expensive regret was an escape value with **underspecified**
//! semantics: passes assumed whatever was locally convenient, and the
//! contradictions took a decade to dig out. The imported rule is that the
//! escape variant answers every capability query with the worst case,
//! from day one, in writing:
//!
//! 1. **May read anything.** An opaque expression is assumed to
//! reference every binding reachable in its scope. No pass may prove
//! a binding unused, unshadowed, or dead across one.
//! 2. **May do anything.** It is assumed to have arbitrary side effects.
//! No pass may drop, duplicate, reorder, or speculate one.
//! 3. **Never constant.** Const-ness classification answers "not
//! constant" ([`OpaqueExpr::is_constant`]). No folding, hoisting, or
//! caching.
//! 4. **Equal to nothing, itself included.** Textual equality never
//! implies semantic equality, so no CSE, deduplication, or
//! memoization keys on an opaque expression. Encoded in the type:
//! neither `OpaqueExpr` nor `ExprRef` implements `PartialEq`.
//! 5. **Emission is byte-verbatim or refusal.** The only sound emission
//! is [`OpaqueExpr::source`] unchanged, into a position whose grammar
//! accepts it verbatim; a target that cannot do that must fail with a
//! diagnostic, never guess.
//!
//! The consequence is deliberate: **every transformation of an opaque
//! expression is unsound by definition**, so the only valid handlings
//! are pass-through and diagnostic. A pass that wants to do better must
//! first move the input out of this class - by widening the retained
//! contract (`crates/vize_armature/src/parser/expression.rs`), which the
//! laws make a monotone, always-safe change.
use Span;
/// Why an expression position carries no AST.
///
/// The classes are exactly the measured retained-`None` shapes (P1-5's
/// contract, P1-9's counters). Two are **text-classifiable** - decidable
/// from the text alone, and the only refusals [`super::JsExpr::parse_in`]
/// produces. The other three are **position-classified**: grammatical
/// facts about where the text came from, assignable only by the lowering
/// that saw the position (P2-8), never recoverable from the text.
/// The escape payload behind [`super::ExprRef::Opaque`]: the classified
/// reason, the exact text, and where it was authored.
///
/// Semantics are the module-level pessimal laws; this type deliberately
/// offers nothing that would make violating them convenient (no
/// `PartialEq`, no accessor that "interprets" the text).
/// See [`crate::op`] for both guard rationales.
const _: = assert!;
const _: = ;