fix #13909 (#13914) [backport:1.2]

Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
cooldome 2020-04-08 10:28:09 +01:00 • committed by GitHub
commit f86fc5316a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 24 deletions

View file

@ -1472,9 +1472,14 @@ proc semProcAnnotation(c: PContext, prc: PNode;
if whichPragma(it) != wInvalid: if whichPragma(it) != wInvalid:
# Not a custom pragma # Not a custom pragma
continue continue
elif strTableGet(c.userPragmas, considerQuotedIdent(c, key)) != nil: else:
# User-defined pragma let ident = considerQuotedIdent(c, key)
continue if strTableGet(c.userPragmas, ident) != nil:
continue # User defined pragma
else:
let sym = searchInScopes(c, ident)
if sym != nil and sfCustomPragma in sym.flags:
continue # User custom pragma
# we transform ``proc p {.m, rest.}`` into ``m(do: proc p {.rest.})`` and # we transform ``proc p {.m, rest.}`` into ``m(do: proc p {.rest.})`` and
# let the semantic checker deal with it: # let the semantic checker deal with it:

View file

@ -1576,8 +1576,14 @@ proc applyTypeSectionPragmas(c: PContext; pragmas, operand: PNode): PNode =
if p.kind == nkEmpty or whichPragma(p) != wInvalid: if p.kind == nkEmpty or whichPragma(p) != wInvalid:
discard "builtin pragma" discard "builtin pragma"
elif strTableGet(c.userPragmas, considerQuotedIdent(c, key)) != nil: else:
let ident = considerQuotedIdent(c, key)
if strTableGet(c.userPragmas, ident) != nil:
discard "User-defined pragma" discard "User-defined pragma"
else:
let sym = searchInScopes(c, ident)
if sym != nil and sfCustomPragma in sym.flags:
discard "Custom user pragma"
else: else:
# we transform ``(arg1, arg2: T) {.m, rest.}`` into ``m((arg1, arg2: T) {.rest.})`` and # we transform ``(arg1, arg2: T) {.m, rest.}`` into ``m((arg1, arg2: T) {.rest.})`` and
# let the semantic checker deal with it: # let the semantic checker deal with it:

View file

@ -335,3 +335,14 @@ ProcDef
static: assert bar("x") == "x" static: assert bar("x") == "x"
#------------------------------------------------------
# issue #13909
template dependency*(id: string, weight = 0.0) {.pragma.}
type
MyObject* = object
provider*: proc(obj: string): pointer {.dependency("Data/" & obj, 16.1), noSideEffect.}
proc myproc(obj: string): string {.dependency("Data/" & obj, 16.1).} =
result = obj