fixes #22362; Compiler crashes with staticBoundsCheck on (#22363)

This commit is contained in:
ringabout
2023-08-02 17:00:34 +08:00
committed by GitHub
parent f3a7622514
commit 825a0e7df4
3 changed files with 19 additions and 0 deletions

View File

@@ -196,6 +196,8 @@ proc newProc*(prc: PSym, module: BModule): BProc =
result = BProc(
prc: prc,
module: module,
optionsStack: if module.initProc != nil: module.initProc.optionsStack
else: @[],
options: if prc != nil: prc.options
else: module.config.options,
blocks: @[initBlock()],

View File

@@ -50,6 +50,7 @@ type
graph: ModuleGraph
config: ConfigRef
sigConflicts: CountTable[SigHash]
initProc: PProc
BModule = ref TJSGen
TJSTypeKind = enum # necessary JS "types"
@@ -158,6 +159,8 @@ proc newProc(globals: PGlobals, module: BModule, procDef: PNode,
options: TOptions): PProc =
result = PProc(
blocks: @[],
optionsStack: if module.initProc != nil: module.initProc.optionsStack
else: @[],
options: options,
module: module,
procDef: procDef,
@@ -3036,6 +3039,7 @@ proc processJSCodeGen*(b: PPassContext, n: PNode): PNode =
if m.module == nil: internalError(m.config, n.info, "myProcess")
let globals = PGlobals(m.graph.backend)
var p = newInitProc(globals, m)
m.initProc = p
p.unique = globals.unique
genModule(p, n)
p.g.code.add(p.locals)

View File

@@ -1,3 +1,7 @@
discard """
targets: "c js"
"""
# test the new pragmas
{.push warnings: off, hints: off.}
@@ -25,3 +29,12 @@ proc foo(x: string, y: int, res: int) =
foo("", 0, 48)
foo("abc", 40, 51)
# bug #22362
{.push staticBoundChecks: on.}
proc main(): void =
{.pop.}
discard
{.push staticBoundChecks: on.}
main()