about summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
* 5853Kartik Agaram2020-01-013-135/+0
* 5852Kartik Agaram2020-01-01232-3/+3
* 5851Kartik Agaram2020-01-0110-20/+22
* 5850 - driver script for translating Mu programsKartik Agaram2020-01-013-0/+69
* 5849 - more integration testing of function callsKartik Agaram2020-01-012-7/+98
* 5848Kartik Agaram2020-01-011-5/+5
* 5847 - literal inputs
discard """
  output: "Valid and not defined"
"""
# test for issue #7997
# checking for `when not defined` in a template for some compile time symbol
# results in a compilation error of:
# Error: obsolete usage of 'defined', use 'declared' instead
# if the symbol is 'overloaded' by some variable or procedure, because in
# that case the argument of `defined` is of kind `nkSym` instead of `nkIdent`
# (for which was checked in `semexprs.semDefined`).

block:
  # check whether a proc with the same name as the argument to `defined`
  # compiles
  proc overloaded() =
    discard

  template definedCheck(): untyped =
    when not defined(overloaded): true
    else: false
  doAssert definedCheck == true

block:
  # check whether a variable with the same name as the argument to `defined`
  # compiles
  var overloaded: int

  template definedCheck(): untyped =
    when not defined(overloaded): true
    else: false
  doAssert definedCheck == true

block:
  # check whether a non overloaded when check still works properly
  when not defined(validIdentifier):
    echo "Valid and not defined"

block:
  # now check that invalid identifiers cause a compilation error
  # by using reject template.
  template reject(b) =
    static: doAssert(not compiles(b))

  reject:
    when defined(123):
      echo "Invalid identifier! Will not be echoed"
>* 5814Kartik Agaram2019-12-211-25/+25 * 5813Kartik Agaram2019-12-211-2/+1 * 5812 - debugging an ancient niggle in browse_traceKartik Agaram2019-12-211-6/+5 * 5811Kartik Agaram2019-12-211-2/+2 * 5810Kartik Agaram2019-12-093-24/+25 * 5809Kartik Agaram2019-12-093-8/+9 * 5808Kartik Agaram2019-12-092-89/+0 * 5807Kartik Agaram2019-12-099-599/+673 * 5806Kartik Agaram2019-12-0979-16594/+16610 * 5805Kartik Agaram2019-12-081-0/+12 * 5804Kartik Agaram2019-12-0868-1078/+1122