diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2015-10-27 23:36:00 +0100 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2015-10-27 23:36:00 +0100 |
commit | 3892969af4a3c6f509b553f07b2a7f37aa8de967 (patch) | |
tree | f4ac158a72b3f520848a479ee4faa8dd68792738 /compiler/trees.nim | |
parent | c7eaa8ae034fc22fcb91770f94e08f7c1ebb9963 (diff) | |
parent | d9415fd5cebdc44385cdd092f2c49060c09e2631 (diff) | |
download | Nim-3892969af4a3c6f509b553f07b2a7f37aa8de967.tar.gz |
Merge branch 'devel'
Diffstat (limited to 'compiler/trees.nim')
-rw-r--r-- | compiler/trees.nim | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/trees.nim b/compiler/trees.nim index 2c631af99..659df334b 100644 --- a/compiler/trees.nim +++ b/compiler/trees.nim @@ -36,15 +36,18 @@ proc cyclicTree*(n: PNode): bool = var s = newNodeI(nkEmpty, n.info) result = cyclicTreeAux(n, s) -proc exprStructuralEquivalent*(a, b: PNode): bool = +proc exprStructuralEquivalent*(a, b: PNode; strictSymEquality=false): bool = result = false if a == b: result = true elif (a != nil) and (b != nil) and (a.kind == b.kind): case a.kind of nkSym: - # don't go nuts here: same symbol as string is enough: - result = a.sym.name.id == b.sym.name.id + if strictSymEquality: + result = a.sym == b.sym + else: + # don't go nuts here: same symbol as string is enough: + result = a.sym.name.id == b.sym.name.id of nkIdent: result = a.ident.id == b.ident.id of nkCharLit..nkInt64Lit: result = a.intVal == b.intVal of nkFloatLit..nkFloat64Lit: result = a.floatVal == b.floatVal @@ -53,7 +56,8 @@ proc exprStructuralEquivalent*(a, b: PNode): bool = else: if sonsLen(a) == sonsLen(b): for i in countup(0, sonsLen(a) - 1): - if not exprStructuralEquivalent(a.sons[i], b.sons[i]): return + if not exprStructuralEquivalent(a.sons[i], b.sons[i], + strictSymEquality): return result = true proc sameTree*(a, b: PNode): bool = |