bugfix: threads should work again; fixes #220
This commit is contained in:
parent
bfda844ccc
commit
1d30798363
3 changed files with 34 additions and 5 deletions
|
|
@ -471,7 +471,8 @@ proc analyseIfAddressTaken(c: PContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkSym:
|
of nkSym:
|
||||||
if skipTypes(n.sym.typ, abstractInst).kind != tyVar:
|
# n.sym.typ can be nil in 'check' mode ...
|
||||||
|
if n.sym.typ != nil and skipTypes(n.sym.typ, abstractInst).kind != tyVar:
|
||||||
incl(n.sym.flags, sfAddrTaken)
|
incl(n.sym.flags, sfAddrTaken)
|
||||||
result = newHiddenAddrTaken(c, n)
|
result = newHiddenAddrTaken(c, n)
|
||||||
of nkDotExpr:
|
of nkDotExpr:
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ proc Lookup(c: PContext, n: PNode, flags: TSemGenericFlags,
|
||||||
if ident.id notin ctx and withinMixin notin flags:
|
if ident.id notin ctx and withinMixin notin flags:
|
||||||
localError(n.info, errUndeclaredIdentifier, ident.s)
|
localError(n.info, errUndeclaredIdentifier, ident.s)
|
||||||
else:
|
else:
|
||||||
if withinMixin in flags:
|
if withinBind in flags:
|
||||||
result = symChoice(c, n, s, scClosed)
|
result = symChoice(c, n, s, scClosed)
|
||||||
elif s.name.id in ctx:
|
elif s.name.id in ctx:
|
||||||
result = symChoice(c, n, s, scForceOpen)
|
result = symChoice(c, n, s, scForceOpen)
|
||||||
|
|
@ -134,26 +134,27 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
if s != nil:
|
if s != nil:
|
||||||
incl(s.flags, sfUsed)
|
incl(s.flags, sfUsed)
|
||||||
isDefinedMagic = s.magic in {mDefined, mDefinedInScope, mCompiles}
|
isDefinedMagic = s.magic in {mDefined, mDefinedInScope, mCompiles}
|
||||||
|
let scOption = if s.name.id in ctx: scForceOpen else: scOpen
|
||||||
case s.kind
|
case s.kind
|
||||||
of skMacro:
|
of skMacro:
|
||||||
if macroToExpand(s):
|
if macroToExpand(s):
|
||||||
result = semMacroExpr(c, n, n, s, false)
|
result = semMacroExpr(c, n, n, s, false)
|
||||||
else:
|
else:
|
||||||
n.sons[0] = symChoice(c, n.sons[0], s, scOpen)
|
n.sons[0] = symChoice(c, n.sons[0], s, scOption)
|
||||||
result = n
|
result = n
|
||||||
of skTemplate:
|
of skTemplate:
|
||||||
if macroToExpand(s):
|
if macroToExpand(s):
|
||||||
let n = fixImmediateParams(n)
|
let n = fixImmediateParams(n)
|
||||||
result = semTemplateExpr(c, n, s, false)
|
result = semTemplateExpr(c, n, s, false)
|
||||||
else:
|
else:
|
||||||
n.sons[0] = symChoice(c, n.sons[0], s, scOpen)
|
n.sons[0] = symChoice(c, n.sons[0], s, scOption)
|
||||||
result = n
|
result = n
|
||||||
# BUGFIX: we must not return here, we need to do first phase of
|
# BUGFIX: we must not return here, we need to do first phase of
|
||||||
# symbol lookup ...
|
# symbol lookup ...
|
||||||
of skUnknown, skParam:
|
of skUnknown, skParam:
|
||||||
# Leave it as an identifier.
|
# Leave it as an identifier.
|
||||||
of skProc, skMethod, skIterator, skConverter:
|
of skProc, skMethod, skIterator, skConverter:
|
||||||
result.sons[0] = symChoice(c, n.sons[0], s, scOpen)
|
result.sons[0] = symChoice(c, n.sons[0], s, scOption)
|
||||||
first = 1
|
first = 1
|
||||||
of skGenericParam:
|
of skGenericParam:
|
||||||
result.sons[0] = newSymNode(s, n.sons[0].info)
|
result.sons[0] = newSymNode(s, n.sons[0].info)
|
||||||
|
|
|
||||||
27
tests/run/tmixin.nim
Normal file
27
tests/run/tmixin.nim
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
discard """
|
||||||
|
output: "1\n2"
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
TFoo1 = object of TObject
|
||||||
|
v: int
|
||||||
|
TFoo2 = object of TFoo1
|
||||||
|
v2: int
|
||||||
|
|
||||||
|
proc test(f: TFoo1) =
|
||||||
|
echo "1"
|
||||||
|
|
||||||
|
proc Foo[T](f: T) =
|
||||||
|
mixin test
|
||||||
|
test(f)
|
||||||
|
|
||||||
|
var
|
||||||
|
a: TFoo1
|
||||||
|
b: TFoo2
|
||||||
|
|
||||||
|
|
||||||
|
proc test(f: TFoo2) =
|
||||||
|
echo "2"
|
||||||
|
|
||||||
|
Foo(a)
|
||||||
|
Foo(b)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue