yglukhov / nimx

GUI library
MIT License
1.1k stars 75 forks source link

Layout DSL doc example incorrect #353

Closed bird closed 5 years ago

bird commented 5 years ago

The example from the layout dsl doc,

import nimx / [ window, button, layout ]

let w = newWindow(newRect(50, 50, 400, 200))
let margin = 5

w.makeLayout:
    - Button:
        leading == super.leading + margin
        trailing == super.trailing - margin
        top == super.top + margin
        bottom == super.bottom - margin

        title: "Hello"
        onAction:
            echo "Action!"

Results in an error of

main.nim(8, 34) Error: type mismatch: got <Expression, int>
but expected one of:
proc `+`(x, y: float32): float32
  first type mismatch at position: 1
  required type: float32
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x, y: float): float
  first type mismatch at position: 1
  required type: float
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x, y: int64): int64
  first type mismatch at position: 1
  required type: int64
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x, y: int32): int32
  first type mismatch at position: 1
  required type: int32
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x: float): float
  first type mismatch at position: 1
  required type: float
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x: int64): int64
  first type mismatch at position: 1
  required type: int64
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x, y: int16): int16
  first type mismatch at position: 1
  required type: int16
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x, y: int): int
  first type mismatch at position: 1
  required type: int
  but expression 'leading(superPHS)' is of type: Expression
proc `+`[T: SomeUnsignedInt](x, y: T): T
  first type mismatch at position: 1
  required type: T: SomeUnsignedInt
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x, y: int8): int8
  first type mismatch at position: 1
  required type: int8
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x: float32): float32
  first type mismatch at position: 1
  required type: float32
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x: int8): int8
  first type mismatch at position: 1
  required type: int8
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x: int32): int32
  first type mismatch at position: 1
  required type: int32
  but expression 'leading(superPHS)' is of type: Expression
proc `+`[T](x, y: set[T]): set[T]
  first type mismatch at position: 1
  required type: set[T]
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x: int): int
  first type mismatch at position: 1
  required type: int
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(x: int16): int16
  first type mismatch at position: 1
  required type: int16
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(p1, p2: Point): Point
  first type mismatch at position: 1
  required type: Point
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(c: Color; v: float32): Color
  first type mismatch at position: 1
  required type: Color
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(c1, c2: Color): Color
  first type mismatch at position: 1
  required type: Color
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(s1, s2: Size): Size
  first type mismatch at position: 1
  required type: Size
  but expression 'leading(superPHS)' is of type: Expression
template `+`(variable: Variable; term: Term): Expression
  first type mismatch at position: 1
  required type: Variable
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(first, second: Term): Expression
  first type mismatch at position: 1
  required type: Term
  but expression 'leading(superPHS)' is of type: Expression
template `+`(expression: Expression; variable: Variable): Expression
  first type mismatch at position: 2
  required type: Variable
  but expression 'margin' is of type: int
template `+`(term: Term; expression: Expression): Expression
  first type mismatch at position: 1
  required type: Term
  but expression 'leading(superPHS)' is of type: Expression
template `+`(term: Term; variable: Variable): Expression
  first type mismatch at position: 1
  required type: Term
  but expression 'leading(superPHS)' is of type: Expression
template `+`(first, second: Variable): Expression
  first type mismatch at position: 1
  required type: Variable
  but expression 'leading(superPHS)' is of type: Expression
template `+`(term: Term; constant: float): Expression
  first type mismatch at position: 1
  required type: Term
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(first, second: Expression): Expression
  first type mismatch at position: 2
  required type: Expression
  but expression 'margin' is of type: int
proc `+`(first: Expression; second: Term): Expression
  first type mismatch at position: 2
  required type: Term
  but expression 'margin' is of type: int
template `+`(variable: Variable; constant: float): Expression
  first type mismatch at position: 1
  required type: Variable
  but expression 'leading(superPHS)' is of type: Expression
proc `+`(expression: Expression; constant: float): Expression
  first type mismatch at position: 2
  required type: float
  but expression 'margin' is of type: int
proc `+`(lhs: float; rhs: Expression | Term | Variable): Expression
  first type mismatch at position: 1
  required type: float
  but expression 'leading(superPHS)' is of type: Expression
template `+`(variable: Variable; expression: Expression): Expression
  first type mismatch at position: 1
  required type: Variable
  but expression 'leading(superPHS)' is of type: Expression

expression: leading(superPHS) + margin