ttryparseexpr.nim 374 B

123456789101112131415161718192021
  1. discard """
  2. outputsub: '''Error: expression expected, but found '[EOF]' 45'''
  3. """
  4. # feature request #1473
  5. import macros
  6. macro test(text: string): untyped =
  7. try:
  8. result = parseExpr(text.strVal)
  9. except ValueError:
  10. result = newLit getCurrentExceptionMsg()
  11. const
  12. valid = 45
  13. a = test("foo&&")
  14. b = test("valid")
  15. c = test("\"") # bug #2504
  16. echo a, " ", b