* fix #16898
* fix #17621

* Update compiler/semtypes.nim
This commit is contained in:
flywind 2021-04-07 00:01:54 +08:00 • committed by GitHub
commit e406e28738
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 3 deletions

31
tests/lent/t16898.nim Normal file
View file

@ -0,0 +1,31 @@
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"
"""
# bug #16898
type
Fp[N: static int, T] = object
big: array[N, T]
type
QuadraticExt* = concept x
## Quadratic Extension concept (like complex)
type BaseField = auto
x.c0 is BaseField
x.c1 is BaseField
{.experimental:"views".}
func prod(r: var QuadraticExt, a, b: lent QuadraticExt) =
discard
type
Fp2[N: static int, T] = object
c0, c1: Fp[N, T]
# This should be passed by reference,
# but concepts do not respect the 24 bytes rule
# or `byref` pragma.
var r, a, b: Fp2[6, uint64]
prod(r, a, b)

15
tests/lent/t17621.nim Normal file
View file

@ -0,0 +1,15 @@
discard """
errormsg: "invalid type: 'lent Test' in this context: 'proc (self: lent Test)' for proc"
"""
# bug #17621
{.experimental: "views".}
type Test = ref object
foo: int
proc modify(self: lent Test) =
self.foo += 1
let test = Test(foo: 12)
modify(test)