'lock levels' are deprecated, now a noop (#20539)

* 'lock levels' are deprecated, now a noop

* fixes tests
This commit is contained in:
ringabout 2022-10-11 15:17:09 +08:00 • committed by GitHub
commit 5602183234
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 121 additions and 372 deletions

View file

@ -1,6 +1,6 @@
discard """
cmd: "nim c --gc:arc $file"
errormsg: "type mismatch: got <proc (a: string, b: sink string){.noSideEffect, gcsafe, locks: 0.}>"
errormsg: "type mismatch: got <proc (a: string, b: sink string){.noSideEffect, gcsafe.}>"
line: 18
"""

View file

@ -1,5 +1,5 @@
discard """
errormsg: "type mismatch: got <proc (s: TScgi: ScgiState or AsyncScgiState) | proc (client: AsyncSocket, headers: StringTableRef, input: string){.noSideEffect, gcsafe, locks: 0.}>"
errormsg: "type mismatch: got <proc (s: TScgi: ScgiState or AsyncScgiState) | proc (client: AsyncSocket, headers: StringTableRef, input: string){.noSideEffect, gcsafe.}>"
line: 23
"""

View file

@ -65,7 +65,7 @@ block tclosure:
# bug #5015
type Mutator = proc(matched: string): string {.noSideEffect, gcsafe, locks: 0.}
type Mutator = proc(matched: string): string {.noSideEffect, gcsafe.}
proc putMutated(
MutatorCount: static[int],

View file

@ -1,5 +1,5 @@
discard """
errormsg: "type mismatch: got <proc (x: int){.nimcall, gcsafe, locks: 0.}>"
errormsg: "type mismatch: got <proc (x: int){.nimcall, gcsafe.}>"
line: 12
"""

View file

@ -1,5 +1,5 @@
discard """
errormsg: "type mismatch: got <proc (){.closure, gcsafe, locks: 0.}> but expected 'A = proc (){.nimcall.}'"
errormsg: "type mismatch: got <proc (){.closure, gcsafe.}> but expected 'A = proc (){.nimcall.}'"
line: 9
"""

View file

@ -33,7 +33,7 @@ py
py
px
6
proc (){.closure, gcsafe, locks: 0.}
proc (){.closure, gcsafe.}
'''
"""

View file

@ -34,7 +34,7 @@ proc foo(x: int): string {.nimcall, raises: [ValueError].} =
var p: MyProcType = foo #[tt.Error
^
type mismatch: got <proc (x: int): string{.nimcall, noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
type mismatch: got <proc (x: int): string{.nimcall, noSideEffect, gcsafe.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.
.raise effects differ
]#

View file

@ -1,6 +1,6 @@
discard """
action: compile
errormsg: "type mismatch: got <proc (x: int){.gcsafe, locks: 0.}>"
errormsg: "type mismatch: got <proc (x: int){.gcsafe.}>"
line: 21
"""

View file

@ -1,6 +1,6 @@
discard """
action: compile
errormsg: "type mismatch: got <proc (i: int){.gcsafe, locks: 0.}>"
errormsg: "type mismatch: got <proc (i: int){.gcsafe.}>"
line: 23
"""

View file

@ -1,5 +1,5 @@
discard """
errormsg: '''type mismatch: got <proc (s: string){.locks: 0.}>'''
errormsg: '''type mismatch: got <proc (s: string)>'''
line: 11
"""
#5620

View file

@ -1,5 +1,5 @@
discard """
errormsg: "invalid type: 'macro (body: untyped): untyped{.noSideEffect, gcsafe, locks: 0.}' for let. Did you mean to call the macro with '()'?"
errormsg: "invalid type: 'macro (body: untyped): untyped{.noSideEffect, gcsafe.}' for let. Did you mean to call the macro with '()'?"
line: 9
"""

View file

@ -1,5 +1,5 @@
discard """
errormsg: "invalid type: 'macro (body: untyped): untyped{.noSideEffect, gcsafe, locks: 0.}' for const. Did you mean to call the macro with '()'?"
errormsg: "invalid type: 'macro (body: untyped): untyped{.noSideEffect, gcsafe.}' for const. Did you mean to call the macro with '()'?"
line: 9
"""

View file

@ -3,8 +3,8 @@ discard """
errormsg: ""
nimout: '''
t18886.nim(18, 24) Error: ambiguous identifier: 'bar' -- you need a helper proc to disambiguate the following:
t18886.bar: proc (i: ptr int){.noSideEffect, gcsafe, locks: 0.}
t18886.bar: proc (i: ptr char){.noSideEffect, gcsafe, locks: 0.}
t18886.bar: proc (i: ptr int){.noSideEffect, gcsafe.}
t18886.bar: proc (i: ptr char){.noSideEffect, gcsafe.}
'''
"""

View file

@ -2,9 +2,9 @@ discard """
cmd: "nim check $options --hints:off $file"
errormsg: ""
nimout: '''
t2614.nim(19, 27) Error: type mismatch: got <array[0..1, proc (){.locks: <unknown>.}]> but expected 'array[0..1, proc (){.closure.}]'
t2614.nim(19, 27) Error: type mismatch: got <array[0..1, proc ()]> but expected 'array[0..1, proc (){.closure.}]'
Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.
t2614.nim(21, 22) Error: type mismatch: got <seq[proc (){.locks: <unknown>.}]> but expected 'seq[proc (){.closure.}]'
t2614.nim(21, 22) Error: type mismatch: got <seq[proc ()]> but expected 'seq[proc (){.closure.}]'
Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.
'''
"""

View file

@ -1,5 +1,5 @@
discard """
errormsg: "type mismatch: got <proc [*missing parameters*](x: int) | proc (x: string){.gcsafe, locks: 0.}>"
errormsg: "type mismatch: got <proc [*missing parameters*](x: int) | proc (x: string){.gcsafe.}>"
line: 19
"""

View file

@ -1,8 +1,8 @@
discard """
cmd: "nim check $file"
errormsg: "type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>"
errormsg: "type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]>"
nimout: '''
tgcsafety.nim(31, 18) Error: type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>
tgcsafety.nim(31, 18) Error: type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]>
but expected one of:
proc serve(server: AsyncHttpServer; port: Port;
callback: proc (request: Request): Future[void] {.closure, gcsafe.};
@ -10,7 +10,7 @@ proc serve(server: AsyncHttpServer; port: Port;
Future[void])
first type mismatch at position: 3
required type for callback: proc (request: Request): Future[system.void]{.closure, gcsafe.}
but expression 'cb' is of type: proc (req: Request): Future[system.void]{.locks: <unknown>.}
but expression 'cb' is of type: proc (req: Request): Future[system.void]
This expression is not GC-safe. Annotate the proc with {.gcsafe.} to get extended error information.
expression: serve(server, Port(7898), cb)

View file

@ -3,36 +3,36 @@ discard """
cmd: '''nim check --hints:off $options $file'''
nimoutFull: true
nimout: '''
tproc_mismatch.nim(38, 52) Error: type mismatch: got <proc (a: int, c: float){.cdecl, noSideEffect, gcsafe, locks: 0.}> but expected 'proc (a: int, c: float){.closure, noSideEffect.}'
tproc_mismatch.nim(38, 52) Error: type mismatch: got <proc (a: int, c: float){.cdecl, noSideEffect, gcsafe.}> but expected 'proc (a: int, c: float){.closure, noSideEffect.}'
Calling convention mismatch: got '{.cdecl.}', but expected '{.closure.}'.
tproc_mismatch.nim(42, 6) Error: type mismatch: got <proc (){.inline, noSideEffect, gcsafe, locks: 0.}>
tproc_mismatch.nim(42, 6) Error: type mismatch: got <proc (){.inline, noSideEffect, gcsafe.}>
but expected one of:
proc bar(a: proc ())
first type mismatch at position: 1
required type for a: proc (){.closure.}
but expression 'fn1' is of type: proc (){.inline, noSideEffect, gcsafe, locks: 0.}
but expression 'fn1' is of type: proc (){.inline, noSideEffect, gcsafe.}
Calling convention mismatch: got '{.inline.}', but expected '{.closure.}'.
expression: bar(fn1)
tproc_mismatch.nim(46, 8) Error: type mismatch: got <proc (){.inline, noSideEffect, gcsafe, locks: 0.}> but expected 'proc (){.closure.}'
tproc_mismatch.nim(46, 8) Error: type mismatch: got <proc (){.inline, noSideEffect, gcsafe.}> but expected 'proc (){.closure.}'
Calling convention mismatch: got '{.inline.}', but expected '{.closure.}'.
tproc_mismatch.nim(51, 8) Error: type mismatch: got <proc (){.locks: 0.}> but expected 'proc (){.closure, noSideEffect.}'
tproc_mismatch.nim(51, 8) Error: type mismatch: got <proc ()> but expected 'proc (){.closure, noSideEffect.}'
Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.
Pragma mismatch: got '{..}', but expected '{.noSideEffect.}'.
tproc_mismatch.nim(55, 8) Error: type mismatch: got <proc (a: int){.noSideEffect, gcsafe, locks: 0.}> but expected 'proc (a: float){.closure.}'
tproc_mismatch.nim(55, 8) Error: type mismatch: got <proc (a: int){.noSideEffect, gcsafe.}> but expected 'proc (a: float){.closure.}'
Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.
tproc_mismatch.nim(64, 9) Error: type mismatch: got <proc (a: int){.locks: 0.}> but expected 'proc (a: int){.closure, gcsafe.}'
tproc_mismatch.nim(64, 9) Error: type mismatch: got <proc (a: int)> but expected 'proc (a: int){.closure, gcsafe.}'
Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.
Pragma mismatch: got '{..}', but expected '{.gcsafe.}'.
tproc_mismatch.nim(72, 9) Error: type mismatch: got <proc (a: int): int{.nimcall.}> but expected 'proc (a: int): int{.cdecl.}'
Calling convention mismatch: got '{.nimcall.}', but expected '{.cdecl.}'.
tproc_mismatch.nim(73, 9) Error: type mismatch: got <proc (a: int): int{.cdecl.}> but expected 'proc (a: int): int{.nimcall.}'
Calling convention mismatch: got '{.cdecl.}', but expected '{.nimcall.}'.
tproc_mismatch.nim(77, 9) Error: type mismatch: got <proc (a: int){.closure, locks: 3.}> but expected 'proc (a: int){.closure, locks: 1.}'
Pragma mismatch: got '{.locks: 3.}', but expected '{.locks: 1.}'.
lock levels differ
'''
"""
block: # CallConv mismatch
func a(a: int, c: float) {.cdecl.} = discard
var b: proc(a: int, c: float) {.noSideEffect.} = a
@ -71,7 +71,4 @@ block: # Indrection through pragmas
var fn2: proc(a: int): int {.inl2, p2.}
fn2 = fn1
fn1 = fn2
block: # Lock levels differ
var fn1: proc(a: int){.locks: 3.}
var fn2: proc(a: int){.locks: 1.}
fn2 = fn1

View file

@ -12,34 +12,34 @@ proc f(b: B)
but expression 'A()' is of type: A
expression: f(A(), "extra")
tsigmatch.nim(125, 6) Error: type mismatch: got <(string, proc (){.gcsafe, locks: 0.})>
tsigmatch.nim(125, 6) Error: type mismatch: got <(string, proc (){.gcsafe.})>
but expected one of:
proc foo(x: (string, proc ()))
first type mismatch at position: 1
required type for x: (string, proc (){.closure.})
but expression '("foobar", proc () = echo(["Hello!"]))' is of type: (string, proc (){.gcsafe, locks: 0.})
but expression '("foobar", proc () = echo(["Hello!"]))' is of type: (string, proc (){.gcsafe.})
expression: foo(("foobar", proc () = echo(["Hello!"])))
tsigmatch.nim(132, 11) Error: type mismatch: got <proc (s: string): string{.noSideEffect, gcsafe, locks: 0.}>
tsigmatch.nim(132, 11) Error: type mismatch: got <proc (s: string): string{.noSideEffect, gcsafe.}>
but expected one of:
proc foo[T, S](op: proc (x: T): S {.cdecl.}): auto
first type mismatch at position: 1
required type for op: proc (x: T): S{.cdecl.}
but expression 'fun' is of type: proc (s: string): string{.noSideEffect, gcsafe, locks: 0.}
but expression 'fun' is of type: proc (s: string): string{.noSideEffect, gcsafe.}
proc foo[T, S](op: proc (x: T): S {.safecall.}): auto
first type mismatch at position: 1
required type for op: proc (x: T): S{.safecall.}
but expression 'fun' is of type: proc (s: string): string{.noSideEffect, gcsafe, locks: 0.}
but expression 'fun' is of type: proc (s: string): string{.noSideEffect, gcsafe.}
expression: foo(fun)
tsigmatch.nim(143, 13) Error: type mismatch: got <array[0..0, proc (x: int){.gcsafe, locks: 0.}]>
tsigmatch.nim(143, 13) Error: type mismatch: got <array[0..0, proc (x: int){.gcsafe.}]>
but expected one of:
proc takesFuncs(fs: openArray[proc (x: int) {.gcsafe, locks: 0.}])
proc takesFuncs(fs: openArray[proc (x: int) {.gcsafe.}])
first type mismatch at position: 1
required type for fs: openArray[proc (x: int){.closure, gcsafe, locks: 0.}]
but expression '[proc (x: int) {.gcsafe, locks: 0.} = echo [x]]' is of type: array[0..0, proc (x: int){.gcsafe, locks: 0.}]
required type for fs: openArray[proc (x: int){.closure, gcsafe.}]
but expression '[proc (x: int) {.gcsafe.} = echo [x]]' is of type: array[0..0, proc (x: int){.gcsafe.}]
expression: takesFuncs([proc (x: int) {.gcsafe, locks: 0.} = echo [x]])
expression: takesFuncs([proc (x: int) {.gcsafe.} = echo [x]])
tsigmatch.nim(149, 4) Error: type mismatch: got <int literal(10), a0: int literal(5), string>
but expected one of:
proc f(a0: uint8; b: string)
@ -135,12 +135,12 @@ block:
# bug #10285 Function signature don't match when inside seq/array/openArray
# Note: the error message now shows `closure` which helps debugging the issue
# out why it doesn't match
proc takesFunc(f: proc (x: int) {.gcsafe, locks: 0.}) =
proc takesFunc(f: proc (x: int) {.gcsafe.}) =
echo "takes single Func"
proc takesFuncs(fs: openArray[proc (x: int) {.gcsafe, locks: 0.}]) =
proc takesFuncs(fs: openArray[proc (x: int) {.gcsafe.}]) =
echo "takes multiple Func"
takesFunc(proc (x: int) {.gcsafe, locks: 0.} = echo x) # works
takesFuncs([proc (x: int) {.gcsafe, locks: 0.} = echo x]) # fails
takesFunc(proc (x: int) {.gcsafe.} = echo x) # works
takesFuncs([proc (x: int) {.gcsafe.} = echo x]) # fails
block:
# bug https://github.com/nim-lang/Nim/issues/11061#issuecomment-508970465

View file

@ -2,10 +2,10 @@ discard """
cmd: "nim check $file"
errormsg: ""
nimout: '''
ttypeAllowed.nim(13, 5) Error: invalid type: 'iterator (a: int, b: int, step: Positive): int{.inline, noSideEffect, gcsafe, locks: 0.}' for let
ttypeAllowed.nim(17, 7) Error: invalid type: 'iterator (a: int, b: int, step: Positive): int{.inline, noSideEffect, gcsafe, locks: 0.}' for const
ttypeAllowed.nim(21, 5) Error: invalid type: 'iterator (a: int, b: int, step: Positive): int{.inline, noSideEffect, gcsafe, locks: 0.}' for var
ttypeAllowed.nim(26, 10) Error: invalid type: 'iterator (a: int, b: int, step: Positive): int{.inline, noSideEffect, gcsafe, locks: 0.}' for result
ttypeAllowed.nim(13, 5) Error: invalid type: 'iterator (a: int, b: int, step: Positive): int{.inline, noSideEffect, gcsafe.}' for let
ttypeAllowed.nim(17, 7) Error: invalid type: 'iterator (a: int, b: int, step: Positive): int{.inline, noSideEffect, gcsafe.}' for const
ttypeAllowed.nim(21, 5) Error: invalid type: 'iterator (a: int, b: int, step: Positive): int{.inline, noSideEffect, gcsafe.}' for var
ttypeAllowed.nim(26, 10) Error: invalid type: 'iterator (a: int, b: int, step: Positive): int{.inline, noSideEffect, gcsafe.}' for result
'''
"""

View file

@ -1,5 +1,5 @@
discard """
errormsg: "type mismatch: got <TT[seq[string]], proc (v: int){.gcsafe, locks: 0.}>"
errormsg: "type mismatch: got <TT[seq[string]], proc (v: int){.gcsafe.}>"
line: 20
"""

View file

@ -1,5 +1,5 @@
discard """
errormsg: "invalid type: 'lent QuadraticExt' in this context: 'proc (r: var QuadraticExt, a: lent QuadraticExt, b: lent QuadraticExt){.noSideEffect, gcsafe, locks: 0.}' for proc"
errormsg: "invalid type: 'lent QuadraticExt' in this context: 'proc (r: var QuadraticExt, a: lent QuadraticExt, b: lent QuadraticExt){.noSideEffect, gcsafe.}' for proc"
"""
# bug #16898

View file

@ -1,5 +1,5 @@
discard """
errormsg: "got <B, proc (b: B){.closure, gcsafe, locks: 0.}>"
errormsg: "got <B, proc (b: B){.closure, gcsafe.}>"
line: 20
"""

View file

@ -1,7 +1,3 @@
discard """
matrix: "--mm:arc; --mm:refc"
"""
type SomeBase* = ref object of RootObj
type SomeDerived* = ref object of SomeBase
memberProc*: proc ()

View file

@ -1,6 +1,6 @@
discard """
errormsg: '''
type mismatch: got <proc (a0: int): string{.noSideEffect, gcsafe, locks: 0.}>
type mismatch: got <proc (a0: int): string{.noSideEffect, gcsafe.}>
'''
line: 13
"""

View file

@ -11,12 +11,12 @@ when not defined(js):
proc staticTz(hours, minutes, seconds: int = 0): Timezone {.noSideEffect.} =
let offset = hours * 3600 + minutes * 60 + seconds
proc zonedTimeFromAdjTime(adjTime: Time): ZonedTime {.locks: 0.} =
proc zonedTimeFromAdjTime(adjTime: Time): ZonedTime =
result.isDst = false
result.utcOffset = offset
result.time = adjTime + initDuration(seconds = offset)
proc zonedTimeFromTime(time: Time): ZonedTime {.locks: 0.}=
proc zonedTimeFromTime(time: Time): ZonedTime =
result.isDst = false
result.utcOffset = offset
result.time = time

View file

@ -361,7 +361,7 @@ block: # bug #14340
envelopeSin[a]()
block:
type Mutator = proc() {.noSideEffect, gcsafe, locks: 0.}
type Mutator = proc() {.noSideEffect, gcsafe.}
proc mutator0() = discard
const mTable = [Mutator(mutator0)]
var i=0