Skip to content

Commit

Permalink
fixes #14444; add genLineDir before assignment (#21201)
Browse files Browse the repository at this point in the history
* fixes #14444; add `genLineDir` before raises

* add a test case

* fixes differently
  • Loading branch information
ringabout authored Dec 29, 2022
1 parent e602ebe commit 705da9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/ccgstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,7 @@ proc genAsgn(p: BProc, e: PNode, fastAsgn: bool) =
initLoc(a, locNone, le, OnUnknown)
a.flags.incl(lfEnforceDeref)
a.flags.incl(lfPrepareForMutation)
genLineDir(p, le) # it can be a nkBracketExpr, which may raise
expr(p, le, a)
a.flags.excl(lfPrepareForMutation)
if fastAsgn: incl(a.flags, lfNoDeepCopy)
Expand Down
14 changes: 14 additions & 0 deletions tests/errmsgs/t14444.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
discard """
matrix: "--hints:off"
exitcode: "1"
output: '''
t14444.nim(13) t14444
fatal.nim(51) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexDefect]
'''
"""

when true: # bug #14444
var i: string
i[10] = 'j'
echo i

0 comments on commit 705da9d

Please sign in to comment.