fixes #11525
This commit is contained in:
parent
48cbf1c496
commit
19b142401c
2 changed files with 39 additions and 2 deletions
|
|
@ -186,7 +186,7 @@ proc isPartOf*(a, b: PNode): TAnalysisResult =
|
||||||
if res != arNo:
|
if res != arNo:
|
||||||
result = res
|
result = res
|
||||||
if res == arYes: break
|
if res == arYes: break
|
||||||
of nkCall:
|
of nkCallKinds:
|
||||||
result = arNo
|
result = arNo
|
||||||
for i in 1 ..< b.len:
|
for i in 1 ..< b.len:
|
||||||
let res = isPartOf(a, b[i])
|
let res = isPartOf(a, b[i])
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''(10, (20, ))
|
output: '''(10, (20, ))
|
||||||
42'''
|
42
|
||||||
|
(x: 900.0, y: 900.0)
|
||||||
|
(x: 900.0, y: 900.0)
|
||||||
|
(x: 900.0, y: 900.0)'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import strutils, sequtils
|
import strutils, sequtils
|
||||||
|
|
@ -37,3 +40,37 @@ var x = X(v: 42)
|
||||||
|
|
||||||
x = X(v: f(x.v))
|
x = X(v: f(x.v))
|
||||||
echo x.v
|
echo x.v
|
||||||
|
|
||||||
|
|
||||||
|
# bug #11525
|
||||||
|
type
|
||||||
|
Point[T] = object
|
||||||
|
x, y: T
|
||||||
|
|
||||||
|
proc adjustPos[T](width, height: int, pos: Point[T]): Point[T] =
|
||||||
|
result = pos
|
||||||
|
|
||||||
|
result = Point[T](
|
||||||
|
x: pos.x - (width / 2),
|
||||||
|
y: pos.y - (height / 2)
|
||||||
|
)
|
||||||
|
|
||||||
|
proc adjustPos2[T](width, height: int, pos: Point[T]): Point[T] =
|
||||||
|
result = pos
|
||||||
|
|
||||||
|
result = Point[T](
|
||||||
|
x: result.x - (width / 2),
|
||||||
|
y: result.y - (height / 2)
|
||||||
|
)
|
||||||
|
|
||||||
|
proc adjustPos3(width, height: int, pos: Point): Point =
|
||||||
|
result = pos
|
||||||
|
|
||||||
|
result = Point(
|
||||||
|
x: result.x - (width / 2),
|
||||||
|
y: result.y - (height / 2)
|
||||||
|
)
|
||||||
|
|
||||||
|
echo adjustPos(200, 200, Point[float](x: 1000, y: 1000))
|
||||||
|
echo adjustPos2(200, 200, Point[float](x: 1000, y: 1000))
|
||||||
|
echo adjustPos3(200, 200, Point[float](x: 1000, y: 1000))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue