ORC: cursor inference bugfix (#17973)
* fixed a .cursor inference bug * added a test case
This commit is contained in:
parent
38b41f893a
commit
c14427dbf3
3 changed files with 50 additions and 5 deletions
|
|
@ -695,7 +695,7 @@ proc traverse(c: var Partitions; n: PNode) =
|
||||||
# 'paramType[0]' is still a view type, this is not a typo!
|
# 'paramType[0]' is still a view type, this is not a typo!
|
||||||
if directViewType(paramType[0]) == noView and classifyViewType(paramType[0]) != noView:
|
if directViewType(paramType[0]) == noView and classifyViewType(paramType[0]) != noView:
|
||||||
borrowingCall(c, paramType[0], n, i)
|
borrowingCall(c, paramType[0], n, i)
|
||||||
elif borrowChecking in c.goals and m == mNone:
|
elif m == mNone:
|
||||||
potentialMutationViaArg(c, n[i], parameters)
|
potentialMutationViaArg(c, n[i], parameters)
|
||||||
|
|
||||||
of nkAddr, nkHiddenAddr:
|
of nkAddr, nkHiddenAddr:
|
||||||
|
|
@ -921,4 +921,4 @@ proc computeCursors*(s: PSym; n: PNode; g: ModuleGraph) =
|
||||||
discard "cannot cursor into a graph that is mutated"
|
discard "cannot cursor into a graph that is mutated"
|
||||||
else:
|
else:
|
||||||
v.sym.flags.incl sfCursor
|
v.sym.flags.incl sfCursor
|
||||||
#echo "this is now a cursor ", v.sym, " ", par.s[rid].flags, " ", config $ v.sym.info
|
#echo "this is now a cursor ", v.sym, " ", par.s[rid].flags, " ", g.config $ v.sym.info
|
||||||
|
|
|
||||||
|
|
@ -362,9 +362,9 @@ proc read*[T](future: Future[T] | FutureVar[T]): T =
|
||||||
##
|
##
|
||||||
## If the result of the future is an error then that error will be raised.
|
## If the result of the future is an error then that error will be raised.
|
||||||
when future is Future[T]:
|
when future is Future[T]:
|
||||||
let fut = future
|
let fut {.cursor.} = future
|
||||||
else:
|
else:
|
||||||
let fut = Future[T](future)
|
let fut {.cursor.} = Future[T](future)
|
||||||
if fut.finished:
|
if fut.finished:
|
||||||
if fut.error != nil:
|
if fut.error != nil:
|
||||||
injectStacktrace(fut)
|
injectStacktrace(fut)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ doing shady stuff...
|
||||||
192.168.0.1
|
192.168.0.1
|
||||||
192.168.0.1
|
192.168.0.1
|
||||||
192.168.0.1'''
|
192.168.0.1'''
|
||||||
cmd: '''nim c --gc:arc --expandArc:newTarget --expandArc:delete --expandArc:p1 --expandArc:tt --hint:Performance:off --assertions:off --expandArc:extractConfig $file'''
|
cmd: '''nim c --gc:arc --expandArc:newTarget --expandArc:delete --expandArc:p1 --expandArc:tt --hint:Performance:off --assertions:off --expandArc:extractConfig --expandArc:mergeShadowScope $file'''
|
||||||
nimout: '''--expandArc: newTarget
|
nimout: '''--expandArc: newTarget
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
@ -108,6 +108,25 @@ try:
|
||||||
`=destroy`(splitted)
|
`=destroy`(splitted)
|
||||||
finally:
|
finally:
|
||||||
`=destroy_1`(lan_ip)
|
`=destroy_1`(lan_ip)
|
||||||
|
--expandArc: mergeShadowScope
|
||||||
|
|
||||||
|
var shadowScope
|
||||||
|
`=copy`(shadowScope, c.currentScope)
|
||||||
|
rawCloseScope(c)
|
||||||
|
block :tmp:
|
||||||
|
var sym
|
||||||
|
var i = 0
|
||||||
|
let L = len(shadowScope.symbols)
|
||||||
|
block :tmp_1:
|
||||||
|
while i < L:
|
||||||
|
var :tmpD
|
||||||
|
sym = shadowScope.symbols[i]
|
||||||
|
addInterfaceDecl(c):
|
||||||
|
wasMoved(:tmpD)
|
||||||
|
`=copy_1`(:tmpD, sym)
|
||||||
|
:tmpD
|
||||||
|
inc(i, 1)
|
||||||
|
`=destroy`(shadowScope)
|
||||||
-- end of expandArc ------------------------'''
|
-- end of expandArc ------------------------'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -277,3 +296,29 @@ proc extractConfig() =
|
||||||
echo splitted[1] # Without this line everything works
|
echo splitted[1] # Without this line everything works
|
||||||
|
|
||||||
extractConfig()
|
extractConfig()
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
Symbol = ref object
|
||||||
|
name: string
|
||||||
|
|
||||||
|
Scope = ref object
|
||||||
|
parent: Scope
|
||||||
|
symbols: seq[Symbol]
|
||||||
|
|
||||||
|
PContext = ref object
|
||||||
|
currentScope: Scope
|
||||||
|
|
||||||
|
proc rawCloseScope(c: PContext) =
|
||||||
|
c.currentScope = c.currentScope.parent
|
||||||
|
|
||||||
|
proc addInterfaceDecl(c: PContext; s: Symbol) =
|
||||||
|
c.currentScope.symbols.add s
|
||||||
|
|
||||||
|
proc mergeShadowScope*(c: PContext) =
|
||||||
|
let shadowScope = c.currentScope
|
||||||
|
c.rawCloseScope
|
||||||
|
for sym in shadowScope.symbols:
|
||||||
|
c.addInterfaceDecl(sym)
|
||||||
|
|
||||||
|
mergeShadowScope(PContext(currentScope: Scope(parent: Scope())))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue