`nim check` fails when checking chame
### Description

Raising here since it seems to be compiler regression.

Ran into this problem when importing the minidom module from [chame](https://git.sr.ht/~bptato/chame)
```nim
import chame/minidom
```

### Nim Version

Nim Compiler Version 2.2.1 [Linux: amd64]
Compiled at 2024-10-11
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: e9a4d096abe8c4abf5cf5ca736828e44ffd691f8
active boot switches: -d:release

### Current Output

```text
/home/jake/Documents/projects/Nim/compiler/nim.nim(169) nim
/home/jake/Documents/projects/Nim/compiler/nim.nim(124) handleCmdLine
/home/jake/Documents/projects/Nim/compiler/main.nim(404) mainCommand
/home/jake/Documents/projects/Nim/compiler/main.nim(96) commandCheck
/home/jake/Documents/projects/Nim/compiler/pipelines.nim(311) compilePipelineProject
/home/jake/Documents/projects/Nim/compiler/pipelines.nim(231) compilePipelineModule
/home/jake/Documents/projects/Nim/compiler/pipelines.nim(177) processPipelineModule
/home/jake/Documents/projects/Nim/compiler/sem.nim(840) semWithPContext
/home/jake/Documents/projects/Nim/compiler/sem.nim(797) semStmtAndGenerateGenerics
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2899) semStmt
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1287) semExprNoType
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/lib/system.nim(918) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3564) semExpr
/home/jake/Documents/projects/Nim/compiler/importer.nim(367) evalImport
/home/jake/Documents/projects/Nim/compiler/importer.nim(335) impMod
/home/jake/Documents/projects/Nim/compiler/importer.nim(293) myImportModule
/home/jake/Documents/projects/Nim/compiler/pipelines.nim(270) importPipelineModule
/home/jake/Documents/projects/Nim/compiler/pipelines.nim(231) compilePipelineModule
/home/jake/Documents/projects/Nim/compiler/pipelines.nim(177) processPipelineModule
/home/jake/Documents/projects/Nim/compiler/sem.nim(840) semWithPContext
/home/jake/Documents/projects/Nim/compiler/sem.nim(797) semStmtAndGenerateGenerics
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2899) semStmt
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1287) semExprNoType
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2846) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3549) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2657) semProc
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2576) semProcAux
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(2125) semProcBody
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2846) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3538) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(110) semWhile
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2899) semStmt
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1287) semExprNoType
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2846) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3533) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(838) semVarOrLet
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(83) semExprWithType
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(67) semExprCheck
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3450) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1177) semIndirectOp
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3434) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1268) semDirectOp
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1072) semOverloadedCallAnalyseEffects
/home/jake/Documents/projects/Nim/compiler/semcall.nim(848) semOverloadedCall
/home/jake/Documents/projects/Nim/compiler/semcall.nim(797) semResolvedCall
/home/jake/Documents/projects/Nim/compiler/seminst.nim(457) generateInstance
/home/jake/Documents/projects/Nim/compiler/seminst.nim(150) instantiateBody
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(2125) semProcBody
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2846) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3538) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(110) semWhile
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2899) semStmt
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1287) semExprNoType
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2846) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3529) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(2069) semAsgn
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(83) semExprWithType
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(67) semExprCheck
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/lib/system.nim(918) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3448) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1268) semDirectOp
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1072) semOverloadedCallAnalyseEffects
/home/jake/Documents/projects/Nim/compiler/semcall.nim(840) semOverloadedCall
/home/jake/Documents/projects/Nim/compiler/semcall.nim(519) resolveOverloads
/home/jake/Documents/projects/Nim/compiler/semcall.nim(107) pickBestCandidate
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(3025) matches
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(2954) matchesAux
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(2745) prepareOperand
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(55) semOperand
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3498) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3448) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1268) semDirectOp
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1072) semOverloadedCallAnalyseEffects
/home/jake/Documents/projects/Nim/compiler/semcall.nim(840) semOverloadedCall
/home/jake/Documents/projects/Nim/compiler/semcall.nim(519) resolveOverloads
/home/jake/Documents/projects/Nim/compiler/semcall.nim(107) pickBestCandidate
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(3025) matches
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(2954) matchesAux
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(2745) prepareOperand
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(55) semOperand
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3450) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1177) semIndirectOp
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3448) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1268) semDirectOp
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1072) semOverloadedCallAnalyseEffects
/home/jake/Documents/projects/Nim/compiler/semcall.nim(848) semOverloadedCall
/home/jake/Documents/projects/Nim/compiler/semcall.nim(797) semResolvedCall
/home/jake/Documents/projects/Nim/compiler/seminst.nim(457) generateInstance
/home/jake/Documents/projects/Nim/compiler/seminst.nim(150) instantiateBody
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(2125) semProcBody
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2846) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3538) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(110) semWhile
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2899) semStmt
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1287) semExprNoType
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/lib/system.nim(918) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3542) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(1334) semCase
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(131) semExprBranchScope
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(124) semExprBranch
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/lib/system.nim(918) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3542) semExpr
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(1351) semCase
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(131) semExprBranchScope
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(124) semExprBranch
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/lib/system.nim(918) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3420) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1269) semDirectOp
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1147) afterCallActions
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(40) semTemplateExpr
/home/jake/Documents/projects/Nim/compiler/sem.nim(450) semAfterMacroCall
/home/jake/Documents/projects/Nim/compiler/semstmts.nim(2899) semStmt
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1287) semExprNoType
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3531) semExpr
/home/jake/Documents/projects/Nim/lib/system.nim(918) semStmtList
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3450) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1177) semIndirectOp
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(3448) semExpr
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1268) semDirectOp
/home/jake/Documents/projects/Nim/compiler/semexprs.nim(1072) semOverloadedCallAnalyseEffects
/home/jake/Documents/projects/Nim/compiler/semcall.nim(840) semOverloadedCall
/home/jake/Documents/projects/Nim/compiler/semcall.nim(519) resolveOverloads
/home/jake/Documents/projects/Nim/compiler/semcall.nim(107) pickBestCandidate
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(3025) matches
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(2955) matchesAux
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(2625) paramTypesMatch
/home/jake/Documents/projects/Nim/compiler/sigmatch.nim(2407) paramTypesMatchAux
/home/jake/Documents/projects/Nim/compiler/sem.nim(369) tryConstExpr
/home/jake/Documents/projects/Nim/compiler/vm.nim(2413) evalConstExpr
/home/jake/Documents/projects/Nim/compiler/vm.nim(2408) evalConstExprAux
/home/jake/Documents/projects/Nim/compiler/vm.nim(935) rawExecute
/home/jake/Documents/projects/Nim/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: index 1 not in 0 .. 0 [IndexDefect]
```


### Expected Output

```text
No Error
```


### Known Workarounds

_No response_

### Additional Information

Bisected and tracked it down to #23625.
Turning on vmTrace the error [seems to be here](https://git.sr.ht/~bptato/chame/tree/fee73e9338d30deedfb58d4bcd85cc1d5fb2c0f0/item/chame/htmltokenizer.nim#L399), I wasn't able to minify to a small test case
```
/home/jake/.nimble/pkgs2/chame-1.0.1-d9f4d89f88b0ba3f4fbcf2326cd5262cbd1d6917/chame/htmltokenizer.nim(392, 27) [opcEof]   template emit(s: static string) =
/home/jake/.nimble/pkgs2/chame-1.0.1-d9f4d89f88b0ba3f4fbcf2326cd5262cbd1d6917/chame/htmltokenizer.nim(402, 21) [opcNew]     emit Token[Atom](t: CHARACTER_NULL)
/home/jake/.nimble/pkgs2/chame-1.0.1-d9f4d89f88b0ba3f4fbcf2326cd5262cbd1d6917/chame/htmltokenizer.nim(402, 25) [opcLdImmInt]     emit Token[Atom](t: CHARACTER_NULL)
/home/jake/.nimble/pkgs2/chame-1.0.1-d9f4d89f88b0ba3f4fbcf2326cd5262cbd1d6917/chame/htmltokenizer.nim(402, 25) [opcWrObj]     emit Token[Atom](t: CHARACTER_NULL)
/home/jake/.nimble/pkgs2/chame-1.0.1-d9f4d89f88b0ba3f4fbcf2326cd5262cbd1d6917/chame/htmltokenizer.nim(402, 21) [opcEof]     emit Token[Atom](t: CHARACTER_NULL)
/home/jake/.nimble/pkgs2/chame-1.0.1-d9f4d89f88b0ba3f4fbcf2326cd5262cbd1d6917/chame/htmltokenizer.nim(399, 5) [opcLdDeref]     tokenizer.emit(ch)
```