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

fix #15035 #15236

Merged
merged 1 commit into from
Aug 28, 2020
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
5 changes: 3 additions & 2 deletions compiler/injectdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,9 @@ proc p(n: PNode; c: var Con; s: var Scope; mode: ProcessMode): PNode =
elif n.kind in {nkObjDownConv, nkObjUpConv}:
result = copyTree(n)
result[0] = p(n[0], c, s, sinkArg)
elif n.typ == nil:
# 'raise X' can be part of a 'case' expression. Deal with it here:
elif n.typ == nil or n.typ.skipTypes({tyGenericInst, tyAlias, tySink, tyVar}).kind == tyOpenArray:
# 'raise X' can be part of a 'case' expression. Deal with it here.
# openarrays require perfect forwarding
result = p(n, c, s, normal)
else:
# copy objects that are not temporary but passed to a 'sink' parameter
Expand Down
16 changes: 16 additions & 0 deletions tests/arc/t14383.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ discard """
output: '''
hello
hello
@[4, 3, 2, 1]
'''
"""

Expand All @@ -11,3 +12,18 @@ import dmodule
var val = parseMinValue()
if val.kind == minDictionary:
echo val


#------------------------------------------------------------------------------
# Issue #15035
#------------------------------------------------------------------------------

proc countRun(lst: sink openArray[int]): int =
discard

proc timSort(lst: var openArray[int]) =
let run = countRun(lst)

var a = @[4, 3, 2, 1]
timSort(a)
echo a