From 1b22a3b346cc1e4260cc92b0d55e667543e4acc4 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 2 Feb 2018 11:00:42 +0100 Subject: [PATCH] disabled non-documented overloading rule for templates and macros --- compiler/sigmatch.nim | 29 ++++++++++++++++------------- lib/pure/securehash.nim | 2 +- tests/macros/tgettypeinst.nim | 4 ++++ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 5d5367460..1e32cfcf2 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1859,19 +1859,22 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType, var r = typeRel(m, f, a) - if r != isNone and m.calleeSym != nil and - m.calleeSym.kind in {skMacro, skTemplate}: - # XXX: duplicating this is ugly, but we cannot (!) move this - # directly into typeRel using return-like templates - incMatches(m, r) - if f.kind == tyStmt: - return arg - elif f.kind == tyTypeDesc: - return arg - elif f.kind == tyStatic: - return arg.typ.n - else: - return argSemantized # argOrig + when false: + # This special typing rule for macros and templates is not documented + # anywhere and breaks symmetry. + if r != isNone and m.calleeSym != nil and + m.calleeSym.kind in {skMacro, skTemplate}: + # XXX: duplicating this is ugly, but we cannot (!) move this + # directly into typeRel using return-like templates + incMatches(m, r) + if f.kind == tyStmt: + return arg + elif f.kind == tyTypeDesc: + return arg + elif f.kind == tyStatic: + return arg.typ.n + else: + return argSemantized # argOrig # If r == isBothMetaConvertible then we rerun typeRel. # bothMetaCounter is for safety to avoid any infinite loop, diff --git a/lib/pure/securehash.nim b/lib/pure/securehash.nim index 57c1f3631..b18095ff6 100644 --- a/lib/pure/securehash.nim +++ b/lib/pure/securehash.nim @@ -67,7 +67,7 @@ proc innerHash(state: var Sha1State, w: var Sha1Buffer) = var round = 0 template rot(value, bits: uint32): uint32 = - (value shl bits) or (value shr (32 - bits)) + (value shl bits) or (value shr (32u32 - bits)) template sha1(fun, val: uint32) = let t = rot(a, 5) + fun + e + val + w[round] diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim index 2f1abe193..d54b99d77 100644 --- a/tests/macros/tgettypeinst.nim +++ b/tests/macros/tgettypeinst.nim @@ -1,6 +1,10 @@ discard """ + disabled: "true" """ +# disabled: relied on undocumented overloading rules. Too much work +# to make this sane. + import macros, strUtils proc symToIdent(x: NimNode): NimNode =