summary refs log tree commit diff stats
path: root/tests/lookups
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lookups')
-rw-r--r--tests/lookups/mambsym3.nim4
-rw-r--r--tests/lookups/mambsym4.nim4
-rw-r--r--tests/lookups/tambsymmanual.nim25
3 files changed, 33 insertions, 0 deletions
diff --git a/tests/lookups/mambsym3.nim b/tests/lookups/mambsym3.nim
new file mode 100644
index 000000000..946a5ff29
--- /dev/null
+++ b/tests/lookups/mambsym3.nim
@@ -0,0 +1,4 @@
+# Module A
+var x*: string
+proc foo*(a: string) =
+  echo "A: ", a
diff --git a/tests/lookups/mambsym4.nim b/tests/lookups/mambsym4.nim
new file mode 100644
index 000000000..ed66cc16d
--- /dev/null
+++ b/tests/lookups/mambsym4.nim
@@ -0,0 +1,4 @@
+# Module B
+var x*: int
+proc foo*(b: int) =
+  echo "B: ", b
diff --git a/tests/lookups/tambsymmanual.nim b/tests/lookups/tambsymmanual.nim
new file mode 100644
index 000000000..3ad91b8cc
--- /dev/null
+++ b/tests/lookups/tambsymmanual.nim
@@ -0,0 +1,25 @@
+discard """
+  output: '''
+A: abc
+B: 123
+A: def
+4
+'''
+"""
+# Module C
+import mambsym3, mambsym4
+
+foo("abc") # A: abc
+foo(123) # B: 123
+let inferred: proc (x: string) = foo
+foo("def") # A: def
+
+doAssert not compiles(write(stdout, x)) # error: x is ambiguous
+write(stdout, mambsym3.x) # no error: qualifier used
+
+proc bar(a: int): int = a + 1
+doAssert bar(x) == x + 1 # no error: only A.x of type int matches
+
+var x = 4
+write(stdout, x) # not ambiguous: uses the module C's x
+echo() # for test output
proved' href='/akspecs/ranger/commit/ranger/data/scope.sh?h=v1.9.2&id=fecebfe81e90d565f4af60c91d3ebc76f29d3c21'>fecebfe8 ^
aa488bd9 ^

fecebfe8 ^

bd156f5c ^
356726c4 ^
aa488bd9 ^
f9e0d5be ^

c84ec5ed ^
f9e0d5be ^






6bd182d8 ^
f9e0d5be ^
43e0f44a ^
bf14a7e7 ^
f9e0d5be ^


94c814a4 ^





f9e0d5be ^


94c814a4 ^
f9e0d5be ^

94c814a4 ^
f9e0d5be ^

94c814a4 ^



bf14a7e7 ^

356726c4 ^
f9e0d5be ^

94c814a4 ^
f9e0d5be ^






94c814a4 ^
43e0f44a ^

43e0f44a ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84