================================================================================
modules/functions
================================================================================

function constant() = 42

function square(x) = x * x

function charAt(str, idx) = str[idx]

moduleVar = 3
function plusModuleVar(x) = x + moduleVar
function plusModuleVar2(x) = "x: \(x) moduleVar: \(moduleVar)"
function nameShadowing(moduleVar) = moduleVar

local localVar = 4
function timesLocalVar(x) = x * localVar

function thisFn() = this.moduleVar

function argCapture(x, y) = new Dynamic { value = x + y + x }

function nestedCapture(a) = new Dynamic {
  b = 3
  c {
    d = a
    x {
      a = 5
      y {
        z = a
      }
    }
  }
}

res1 = constant()
res2 = square(3)
res3 = charAt("abcdef", 4)
res4 = plusModuleVar(8)
res5 = plusModuleVar2(5)
res6 = nameShadowing(7)
res7 = timesLocalVar(2)
res8 = thisFn()
res9 = this.thisFn()
res10 = argCapture(4, 5).value
res11 = nestedCapture(99)

--------------------------------------------------------------------------------

(module
  (classMethod
    (methodHeader
      (identifier)
      (parameterList))
    (intLiteral))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (binaryExpr
      (variableExpr
        (identifier))
      (variableExpr
        (identifier))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))
        (typedIdentifier
          (identifier))))
    (subscriptExpr
      (variableExpr
        (identifier))
      (variableExpr
        (identifier))))
  (classProperty
    (identifier)
    (intLiteral))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (binaryExpr
      (variableExpr
        (identifier))
      (variableExpr
        (identifier))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (slStringLiteral
      (interpolationExpr
        (variableExpr
          (identifier)))
      (interpolationExpr
        (variableExpr
          (identifier)))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (variableExpr
      (identifier)))
  (classProperty
    (modifier)
    (identifier)
    (intLiteral))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (binaryExpr
      (variableExpr
        (identifier))
      (variableExpr
        (identifier))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList))
    (propertyCallExpr
      (thisExpr)
      (identifier)))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))
        (typedIdentifier
          (identifier))))
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (binaryExpr
            (binaryExpr
              (variableExpr
                (identifier))
              (variableExpr
                (identifier)))
            (variableExpr
              (identifier)))))))
  (classMethod
    (methodHeader
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier))))
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (intLiteral))
        (objectProperty
          (identifier)
          (objectBody
            (objectProperty
              (identifier)
              (variableExpr
                (identifier)))
            (objectProperty
              (identifier)
              (objectBody
                (objectProperty
                  (identifier)
                  (intLiteral))
                (objectProperty
                  (identifier)
                  (objectBody
                    (objectProperty
                      (identifier)
                      (variableExpr
                        (identifier))))))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList)))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (intLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (slStringLiteral)
        (intLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (intLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (intLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (intLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (intLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList)))
  (classProperty
    (identifier)
    (methodCallExpr
      (thisExpr)
      (identifier)
      (argumentList)))
  (classProperty
    (identifier)
    (propertyCallExpr
      (methodCallExpr
        (identifier)
        (argumentList
          (intLiteral)
          (intLiteral)))
      (identifier)))
  (classProperty
    (identifier)
    (methodCallExpr
      (identifier)
      (argumentList
        (intLiteral)))))
