Repository navigation
Commit 387fa75
committed
fix: close the holes the audit found in its own guards
Reintroducing each defect and counting the reds surfaced four places where the
branch guarded less than it claimed, and two sibling defects of the same class
as the ones it fixes. Counts here are whole-suite, and exclude the three
pre-existing Windows babel-plugin-tester failures.
The isolation scan had a hole it could not see
----------------------------------------------
native-runtime-isolation restated its own plane census as ["native",
"native-internal"], and the ways into the native plane are not directory
names. src/index.ts re-exports runtime, and runtime is runtime.native on the
native platform, so `import "react-native-css"` in a compiler source resolves
to `index` — not under either directory, and pulling all of both. Measured
against the census form: that import, `import "../runtime.native"` and
`import "react-native-css/runtime"` each reddened zero cases while producing
exactly the dist defect the VAR_SYMBOL fix exists to prevent.
So the census is gone and the question is reachability: can the module a
specifier resolves to reach native/reactivity, through any number of hops and
on any platform. That is the fact the invariant actually rests on — the
listeners — rather than a second name for it. All three specifiers now redden
the scan, and so does a path through a third directory, which no scan of
src/compiler/ alone could see: a value import of the runtime added to
src/utilities reddens four cases, the scan among them.
Two guards go with it. The detector walks the whole tree rather than the
top-level statements, so a require() or a dynamic import() inside a function
body is a module reference it can find; and a reachability table states what
the check discriminates, so a renamed native/reactivity fails loudly instead
of making every answer false.
compiler/inheritance.test.ts stays in the scan. It sits in that directory
rather than under __tests__, so bob compiles it into dist and the package
ships it, which makes it a compiler source like any other.
One comparison, not one and a half
----------------------------------
compare.ts claimed an operator has exactly one meaning at runtime, and `=` had
two: the container evaluator short-circuited it before reaching the primitive,
because a keyword feature like orientation answers a string. Measured:
deciding `=` wrongly inside the primitive reddened 8 cases and none of them
under @container, whose table holds (width = 400px) rows.
The primitive takes StyleDescriptor now and answers `=` itself, since
narrowing at the call site is how the second copy got written — an evaluator
that must reject a keyword before it can call the primitive ends up deciding
equality on its own. Both evaluators hand it whatever the feature answered and
nothing else. The same mutation now reddens 14, six under @container,
including the orientation rows.
The numeric guard travels with it, so testMediaFeatureInterval holds none of
its own: an unmeasured value or an unresolved bound fails whichever comparison
it is an operand of. That guard was observed by nothing — dropping it reddened
zero — because the cases that looked like they pinned it return false either
way. "landscape" < 800 is NaN < 800; only a string that COERCES tells the two
apart, and 400 < "500" is 400 < 500. Three rows cover it now, one per slot,
each mutation-proven.
Two sibling defects, same class
-------------------------------
inline-size and block-size compile cleanly and answered undefined, so
@container (min-inline-size: 400px) matched nothing at any size — on the axis
container-type: inline-size names, which is the one most container queries are
written against. React Native lays out in one writing mode, so inline is the
width axis and block the height axis. Reverting reddens 5.
A <ratio> with a zero denominator has no finite quotient, and
(min-aspect-ratio: 1/0) emitted Infinity. The native injection path serialises
through JSON.stringify, which writes Infinity and NaN as null, so the
condition meant one thing under jest and another on a device. A degenerate
ratio is refused instead, which routes it into the same "did not compile" path
as every other unresolvable value. Reverting reddens 3.
Assertions that could not fail
------------------------------
Five expect(cases).toHaveLength(census.length * ORDERINGS.length) compared a
generated table against the generator that made it, so the product held for
any census. Deleting "<" from the operator census removes 19 cases across four
files and left all five green; only compare.test.ts's comparison against
COMPARISON_MATCHES — a total Record over MediaFeatureComparison, whose keys
are the union itself — noticed. Every table asserts coverage against that
record now, and the same deletion reddens 5 tests in 5 suites.
conditional-group-rules's control table asserted only that one rule came out,
never which condition it carried, so a block emitted with the wrong condition
— or with none — passed it. Each case names the condition now, including the
two preludes that legitimately carry none.
And the aspect-ratio and interval tables get the label they were missing: a
matches: true row and a matches: false row fail under opposite defects, one
for a block that stops being emitted and one for a block emitted with nothing
to check. Neither half observes the other's direction, which is why both are
there and why the size of a table is not its coverage.
Corrections to what was claimed
-------------------------------
- The audit table's "an interval's bounds swapped in the emit (@media)" row
reads 0 -> 5. Measured whole-suite it is 9, of which 5 are the
compiler-plane pins and 4 the runtime rows that already existed one commit
earlier — so the head column is 4, not 0. Zero is the figure against the
base, where an unevaluated interval cannot observe its own layout. Both
readings of "swapped bounds" give the same numbers.
- That table's counting rule is not constant across its rows: the 5 there
counts the compiler plane only, while other rows count the whole suite. The
counts above use one rule throughout.
- "import VAR_SYMBOL for its type only" says the emitted declaration file is
unchanged. It is not: compiler.types.d.ts carries `import type { VAR_SYMBOL
}` where it carried `import { VAR_SYMBOL }`, and a declaration emit diffs in
exactly that one line and nowhere else. Inert for consumers, but not
nothing.
- "evaluate interval (range pair) conditions" says it dissolves the last
identical-bodied switch arms under src/native/conditions. That holds within
each switch and not across the two files: `case "!!": return false` is the
same body in both, and it is a gap rather than a decision.
Known limits, now stated where the decision is made
---------------------------------------------------
A comma-separated media query list is intersected, not unioned. rule.m is a
flat array fed from two places with opposite meanings — one entry per comma
branch, which CSS unions, and one per enclosing @media block or
media-carrying selector, which CSS intersects — and testMediaQuery intersects
the whole array. Measured: @media (min-width: 400px), (min-height: 300px) at
600x200 does not match while (min-width: 400px) alone does, and switching the
evaluator to .some(...) fixes the list and breaks nesting — @media (min-width:
400px) { @media (min-height: 900px) { ... } } starts matching at 600x200. The
existing suite catches neither direction, so the substitution passes it. Two
entries of the same shape mean two different things; the emit has to say
which, which is a change to what is produced rather than to how it is read. It
is left standing and written down at the every(never) decision it sits beside,
and at the evaluator a reader would otherwise reach for.
The boolean context is unimplemented on both planes: (width) compiles to
["!!", name] and both evaluators answer false, so the query reads as valid and
can never match. Answering it needs a truthiness rule per feature.
Suite: 1361, up from 1325. Two runs with identical totals, zero suite-load
failures. yarn typecheck and yarn lint exit 0.1 parent 3bacba9 commit 387fa75
13 files changed
Lines changed: 600 additions & 114 deletions
File tree
- src
- __tests__
- compiler
- native
- compiler
- native/conditions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
15 | 31 | | |
16 | 32 | | |
17 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
44 | 60 | | |
45 | 61 | | |
46 | 62 | | |
| |||
56 | 72 | | |
57 | 73 | | |
58 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
59 | 87 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 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 | + | |
65 | 113 | | |
66 | 114 | | |
67 | 115 | | |
| 116 | + | |
68 | 117 | | |
69 | 118 | | |
70 | 119 | | |
71 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
72 | 127 | | |
73 | 128 | | |
74 | 129 | | |
75 | | - | |
76 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
77 | 134 | | |
78 | 135 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
| |||
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
70 | 81 | | |
71 | 82 | | |
72 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
132 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
| |||
0 commit comments