mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-11 22:08:54 +00:00
add test to close #7223, close #11733 closes #7223, closes #11733, were fixed by #22076
This commit is contained in:
@@ -20,3 +20,31 @@ proc bar(a: string): string =
|
||||
template baz*(a: string): string =
|
||||
var b = a.bar()
|
||||
b
|
||||
|
||||
# issue #7223
|
||||
|
||||
import mdotcall2
|
||||
|
||||
type
|
||||
Bytes* = seq[byte]
|
||||
|
||||
BytesRange* = object
|
||||
bytes*: Bytes
|
||||
ibegin*, iend*: int
|
||||
|
||||
proc privateProc(r: BytesRange): int = r.ibegin
|
||||
|
||||
template rangeBeginAddr*(r: BytesRange): pointer =
|
||||
r.bytes.baseAddr.shift(r.privateProc)
|
||||
|
||||
# issue #11733
|
||||
|
||||
type ObjA* = object
|
||||
|
||||
proc foo2(o: var ObjA) = discard
|
||||
proc bar2(o: var ObjA, arg: Natural) = discard
|
||||
|
||||
template publicTemplateObjSyntax*(o: var ObjA, arg: Natural, doStuff: untyped) =
|
||||
o.foo2()
|
||||
doStuff
|
||||
o.bar2(arg)
|
||||
|
||||
7
tests/template/mdotcall2.nim
Normal file
7
tests/template/mdotcall2.nim
Normal file
@@ -0,0 +1,7 @@
|
||||
# imported by mdotcall
|
||||
|
||||
proc baseAddr*[T](x: openarray[T]): pointer =
|
||||
cast[pointer](x)
|
||||
|
||||
proc shift*(p: pointer, delta: int): pointer =
|
||||
cast[pointer](cast[int](p) + delta)
|
||||
@@ -1,10 +1,20 @@
|
||||
import mdotcall
|
||||
|
||||
# issue #20073
|
||||
works()
|
||||
boom()
|
||||
block: # issue #20073
|
||||
works()
|
||||
boom()
|
||||
|
||||
# issue #7085
|
||||
doAssert baz("hello") == "hellobar"
|
||||
doAssert baz"hello" == "hellobar"
|
||||
doAssert "hello".baz == "hellobar"
|
||||
block: # issue #7085
|
||||
doAssert baz("hello") == "hellobar"
|
||||
doAssert baz"hello" == "hellobar"
|
||||
doAssert "hello".baz == "hellobar"
|
||||
|
||||
block: # issue #7223
|
||||
var r = BytesRange(bytes: @[1.byte, 2, 3], ibegin: 0, iend: 2)
|
||||
var a = r.rangeBeginAddr
|
||||
|
||||
block: # issue #11733
|
||||
var a: ObjA
|
||||
var evaluated = false
|
||||
a.publicTemplateObjSyntax(42): evaluated = true
|
||||
doAssert evaluated
|
||||
|
||||
Reference in New Issue
Block a user