mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 03:32:32 +00:00
This reverts commit d566d21730.
This commit is contained in:
@@ -1307,7 +1307,7 @@ proc implicitPragmas*(c: PContext, sym: PSym, info: TLineInfo,
|
||||
if sym != nil and sym.kind != skModule:
|
||||
for it in c.optionStack:
|
||||
let o = it.otherPragmas
|
||||
if not o.isNil:
|
||||
if not o.isNil and sfFromGeneric notin sym.flags: # see issue #12985
|
||||
pushInfoContext(c.config, info)
|
||||
var i = 0
|
||||
while i < o.len:
|
||||
|
||||
@@ -386,17 +386,11 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
|
||||
entry.compilesId = c.compilesContextId
|
||||
addToGenericProcCache(c, fn, entry)
|
||||
c.generics.add(makeInstPair(fn, entry))
|
||||
# bug #12985 bug #22913
|
||||
# TODO: use the context of the declaration of generic functions instead
|
||||
# TODO: consider fixing options as well
|
||||
let otherPragmas = c.optionStack[^1].otherPragmas
|
||||
c.optionStack[^1].otherPragmas = nil
|
||||
if n[pragmasPos].kind != nkEmpty:
|
||||
pragma(c, result, n[pragmasPos], allRoutinePragmas)
|
||||
if isNil(n[bodyPos]):
|
||||
n[bodyPos] = copyTree(getBody(c.graph, fn))
|
||||
instantiateBody(c, n, fn.typ.n, result, fn)
|
||||
c.optionStack[^1].otherPragmas = otherPragmas
|
||||
sideEffectsCheck(c, result)
|
||||
if result.magic notin {mSlice, mTypeOf}:
|
||||
# 'toOpenArray' is special and it is allowed to return 'openArray':
|
||||
|
||||
@@ -38,42 +38,3 @@ proc main(): void =
|
||||
{.push staticBoundChecks: on.}
|
||||
|
||||
main()
|
||||
|
||||
|
||||
proc timnFoo[T](obj: T) {.noSideEffect.} = discard # BUG
|
||||
|
||||
{.push exportc.}
|
||||
proc foo1() =
|
||||
var s1 = "bar"
|
||||
timnFoo(s1)
|
||||
var s2 = @[1]
|
||||
timnFoo(s2)
|
||||
{.pop.}
|
||||
|
||||
|
||||
block: # bug #22913
|
||||
block:
|
||||
type r = object
|
||||
|
||||
template std[T](x: T) =
|
||||
let ttt {.used.} = x
|
||||
result = $ttt
|
||||
|
||||
proc bar[T](x: T): string =
|
||||
std(x)
|
||||
|
||||
{.push exportc: "$1".}
|
||||
proc foo(): r =
|
||||
let s = bar(123)
|
||||
{.pop.}
|
||||
|
||||
discard foo()
|
||||
|
||||
block:
|
||||
type r = object
|
||||
{.push exportc: "$1".}
|
||||
proc foo2(): r =
|
||||
let s = $result
|
||||
{.pop.}
|
||||
|
||||
discard foo2()
|
||||
|
||||
Reference in New Issue
Block a user