tambsymmanual.nim 497 B

1234567891011121314151617181920212223242526
  1. discard """
  2. output: '''
  3. A: abc
  4. B: 123
  5. A: def
  6. 4
  7. '''
  8. """
  9. # Module C
  10. import mambsym3, mambsym4
  11. foo("abc") # A: abc
  12. foo(123) # B: 123
  13. let inferred: proc (x: string) = foo
  14. foo("def") # A: def
  15. doAssert not compiles(write(stdout, x)) # error: x is ambiguous
  16. write(stdout, mambsym3.x) # no error: qualifier used
  17. proc bar(a: int): int = a + 1
  18. doAssert bar(x) == x + 1 # no error: only A.x of type int matches
  19. var x = 4
  20. write(stdout, x) # not ambiguous: uses the module C's x
  21. echo() # for test output