Commit 6bc715a
committed
chore(typst): clean up dead code and one more global leak
- parse_multiple was declared without `local`, leaking as a global on
every module load. Made it `local function` (forward use in
translate_border still works since the local is declared above).
- Removed `set_brand_mode = set_brand_mode,` from the export table:
set_brand_mode is never defined in this module and has no callers
anywhere, so the export silently resolved to nil — a phantom API
surface.
- Removed dead `local mult = 1` initial assignment (immediately
overwritten in every branch); now just `local mult` then assigned.
- Removed unused `local dash` in translate_border_style.
- Removed a duplicate `local function quote(s)` definition (two
identical copies of the same function body, the first one dead).
- Removed a trailing-whitespace nit.
Two regression tests added in tests/unit-lua/typst-css.test.lua:
- TestModuleNoGlobalLeak.testParseMultipleNotGlobal — `_G.parse_multiple`
must be nil after the module loads.
- TestModuleExports.testNoPhantomExports — every key listed on the LHS
of the module's `return { ... }` block must resolve to a non-nil
value on the loaded module. (pairs() can't see this because Lua
tables drop nil-valued keys, so the test reads the source file.)1 parent 736b949 commit 6bc715a
2 files changed
Lines changed: 42 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
360 | | - | |
| 360 | + | |
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | | - | |
| 556 | + | |
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
570 | | - | |
| 570 | + | |
571 | 571 | | |
572 | 572 | | |
573 | 573 | | |
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | 596 | | |
601 | 597 | | |
602 | 598 | | |
| |||
660 | 656 | | |
661 | 657 | | |
662 | 658 | | |
663 | | - | |
664 | 659 | | |
665 | 660 | | |
666 | 661 | | |
| |||
777 | 772 | | |
778 | 773 | | |
779 | 774 | | |
780 | | - | |
781 | 775 | | |
782 | 776 | | |
783 | 777 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
229 | 268 | | |
0 commit comments