Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #22362; Compiler crashes with staticBoundsCheck on #22363

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/cgendata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
Expand Down
4 changes: 4 additions & 0 deletions compiler/jsgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type
graph: ModuleGraph
config: ConfigRef
sigConflicts: CountTable[SigHash]
initProc: PProc

BModule = ref TJSGen
TJSTypeKind = enum # necessary JS "types"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions tests/pragmas/tpush.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
discard """
targets: "c js"
"""

# test the new pragmas

{.push warnings: off, hints: off.}
Expand Down Expand Up @@ -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()