File: tinvalidborrow.nim

package info (click to toggle)
nim 2.2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,951,164 kB
  • sloc: sh: 24,599; ansic: 1,771; python: 1,493; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (42 lines) | stat: -rw-r--r-- 1,073 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
discard """
  cmd: "nim check --hints:off --warnings:off $file"
  action: "reject"
  nimout:'''
tinvalidborrow.nim(25, 3) Error: only a 'distinct' type can borrow `.`
tinvalidborrow.nim(26, 3) Error: only a 'distinct' type can borrow `.`
tinvalidborrow.nim(27, 1) Error: borrow proc without distinct type parameter is meaningless
tinvalidborrow.nim(36, 1) Error: borrow with generic parameter is not supported
tinvalidborrow.nim(41, 1) Error: borrow from proc return type mismatch: 'T'
tinvalidborrow.nim(42, 1) Error: borrow from '[]=' is not supported
'''
"""





# bug #516

type
  TAtom = culong
  Test {.borrow:`.`.} = distinct int
  Foo[T] = object
    a: int
  Bar[T] {.borrow:`.`.} = Foo[T]
  OtherFoo {.borrow:`.`.} = Foo[int]
proc `==`*(a, b: TAtom): bool {.borrow.}

var
  d, e: TAtom

discard( $(d == e) )

# issue #4121
type HeapQueue[T] = distinct seq[T]
proc len*[T](h: HeapQueue[T]): int {.borrow.}

# issue #3564
type vec4[T] = distinct array[4, float32]

proc `[]`(v: vec4, i: int): float32 {.borrow.}
proc `[]=`(v: vec4, i: int, va: float32) {.borrow.}