diff options
author | Araq <rumpf_a@web.de> | 2012-11-18 01:36:20 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-11-18 01:36:20 +0100 |
commit | 3c0a6a89629884b652bf351cb0cee5c94548effc (patch) | |
tree | f9053489e93a46e47701a8218d7cc9bd4b92b97f /compiler | |
parent | 7f6633a06feeac8d6bd1eb1e6d8e841591326618 (diff) | |
download | Nim-3c0a6a89629884b652bf351cb0cee5c94548effc.tar.gz |
'assert' hides EAssertionFailsure; stdlib makes use of 'tags'
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/condsyms.nim | 1 | ||||
-rw-r--r-- | compiler/sempass2.nim | 12 | ||||
-rwxr-xr-x | compiler/types.nim | 11 |
3 files changed, 17 insertions, 7 deletions
diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index f8f3c9dee..234029ea9 100755 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -59,6 +59,7 @@ proc InitDefines*() = DefineSymbol("nimhygiene") DefineSymbol("niminheritable") DefineSymbol("nimmixin") + DefineSymbol("nimeffects") # add platform specific symbols: case targetCPU diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 59ae26385..c3e2ce8bc 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -102,7 +102,8 @@ proc addEffect(a: PEffects, e: PNode, useLineInfo=true) = throws(a.exc, e) proc mergeEffects(a: PEffects, b: PNode, useLineInfo: bool) = - for effect in items(b): addEffect(a, effect, useLineInfo) + if not b.isNil: + for effect in items(b): addEffect(a, effect, useLineInfo) proc addTag(a: PEffects, e: PNode, useLineInfo=true) = var aa = a.tags @@ -113,7 +114,8 @@ proc addTag(a: PEffects, e: PNode, useLineInfo=true) = throws(a.tags, e) proc mergeTags(a: PEffects, b: PNode, useLineInfo: bool) = - for effect in items(b): addTag(a, effect, useLineInfo) + if not b.isNil: + for effect in items(b): addTag(a, effect, useLineInfo) proc listEffects(a: PEffects) = for e in items(a.exc): Message(e.info, hintUser, typeToString(e.typ)) @@ -125,7 +127,7 @@ proc catches(tracked: PEffects, e: PType) = var i = tracked.bottom while i < L: # r supertype of e? - if inheritanceDiff(tracked.exc[i].excType, e) <= 0: + if safeInheritanceDiff(tracked.exc[i].excType, e) <= 0: tracked.exc.sons[i] = tracked.exc.sons[L-1] dec L else: @@ -272,7 +274,7 @@ proc checkRaisesSpec(spec, real: PNode, msg: string, hints: bool) = for r in items(real): block search: for s in 0 .. <spec.len: - if inheritanceDiff(r.excType, spec[s].typ) <= 0: + if safeInheritanceDiff(r.excType, spec[s].typ) <= 0: used.incl(s) break search # XXX call graph analysis would be nice here! @@ -341,6 +343,6 @@ proc trackProc*(s: PSym, body: PNode) = let tagsSpec = effectSpec(p, wTags) if not isNil(tagsSpec): checkRaisesSpec(tagsSpec, t.tags, "can have an unlisted effect: ", - hints=on) + hints=off) # after the check, use the formal spec: effects.sons[tagEffects] = tagsSpec diff --git a/compiler/types.nim b/compiler/types.nim index c994e0dd8..afc05d773 100755 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1190,16 +1190,23 @@ proc baseOfDistinct*(t: PType): PType = internalAssert parent != nil parent.sons[0] = it.sons[0] +proc safeInheritanceDiff*(a, b: PType): int = + # same as inheritanceDiff but checks for tyError: + if a.kind == tyError or b.kind == tyError: + result = -1 + else: + result = inheritanceDiff(a, b) + proc compatibleEffectsAux(se, re: PNode): bool = if re.isNil: return false for r in items(re): block search: for s in items(se): - if inheritanceDiff(r.typ, s.typ) <= 0: + if safeInheritanceDiff(r.typ, s.typ) <= 0: break search return false result = true - + proc compatibleEffects*(formal, actual: PType): bool = # for proc type compatibility checking: assert formal.kind == tyProc and actual.kind == tyProc |