getCustomPragmaVal priority/override fixes (#17725)
* Adhere left-to-right rule for custom pragma priority * Improve error message for no custom pragmas * custom pragmas on var/let sym take priority over its type ones * Workaround & bug
This commit is contained in:
parent
da1c1a7117
commit
7c64e49d45
2 changed files with 50 additions and 38 deletions
|
|
@ -165,11 +165,14 @@ type
|
|||
let a {.defaultValue(4).}: proc(x: int) = nil
|
||||
var b: MyAnnotatedProcType = nil
|
||||
var c: proc(x: int): void {.defaultValue(5).} = nil
|
||||
var d {.defaultValue(44).}: MyAnnotatedProcType = nil
|
||||
static:
|
||||
doAssert hasCustomPragma(a, defaultValue)
|
||||
doAssert hasCustomPragma(MyAnnotatedProcType, defaultValue)
|
||||
doAssert hasCustomPragma(b, defaultValue)
|
||||
doAssert hasCustomPragma(typeof(c), defaultValue)
|
||||
doAssert getCustomPragmaVal(d, defaultValue) == 44
|
||||
doAssert getCustomPragmaVal(typeof(d), defaultValue) == 4
|
||||
|
||||
# bug #8371
|
||||
template thingy {.pragma.}
|
||||
|
|
@ -405,3 +408,10 @@ template hehe(key, val: string, haha) {.pragma.}
|
|||
type A {.haha, hoho, haha, hehe("hi", "hu", "he").} = int
|
||||
|
||||
assert A.getCustomPragmaVal(hehe) == (key: "hi", val: "hu", haha: "he")
|
||||
|
||||
template hehe(key, val: int) {.pragma.}
|
||||
|
||||
var bb {.haha, hoho, hehe(1, 2), haha, hehe("hi", "hu", "he").} = 3
|
||||
|
||||
# left-to-right priority/override order for getCustomPragmaVal
|
||||
assert bb.getCustomPragmaVal(hehe) == (key: "hi", val: "hu", haha: "he")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue