about summary refs log tree commit diff stats
path: root/021check_instruction.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-15 01:02:53 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-15 01:02:53 -0800
commit687dd3f5da63bee9dd310bc4ac2844ece43e3fba (patch)
tree3e57d03f17a59c97a9ba10b15ee87084eced66e1 /021check_instruction.cc
parentef96f57ce264c8e0bd98f6e8622d1c1e2eceafb2 (diff)
downloadmu-687dd3f5da63bee9dd310bc4ac2844ece43e3fba.tar.gz
2442
Fix the drawback in the previous commit: if an ingredient is just a
literal 0 we'll skip its type-checking and hope to map type ingredients
elsewhere.
Diffstat (limited to '021check_instruction.cc')
-rw-r--r--021check_instruction.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/021check_instruction.cc b/021check_instruction.cc
index fc1f0a1f..15d14afc 100644
--- a/021check_instruction.cc
+++ b/021check_instruction.cc
@@ -79,17 +79,16 @@ bool types_match(reagent lhs, reagent rhs) {
   // to sidestep type-checking, use /raw in the source.
   // this is unsafe, and will be highlighted in red inside vim. just for some tests.
   if (is_raw(rhs)) return true;
-  // allow writing 0 to any address
-  if (rhs.name == "0" && is_mu_address(lhs)) return true;
-  if (is_literal(rhs)) return valid_type_for_literal(lhs) && size_of(rhs) == size_of(lhs);
+  if (is_literal(rhs)) return valid_type_for_literal(lhs, rhs) && size_of(rhs) == size_of(lhs);
   if (!lhs.type) return !rhs.type;
   return types_match(lhs.type, rhs.type);
 }
 
-bool valid_type_for_literal(const reagent& r) {
-  if (is_mu_array(r)) return false;
-  if (is_mu_address(r)) return false;
+bool valid_type_for_literal(const reagent& lhs, const reagent& literal_rhs) {
+  if (is_mu_array(lhs)) return false;
   // End valid_type_for_literal Special-cases
+  // allow writing 0 to any address
+  if (is_mu_address(lhs)) return literal_rhs.name == "0";
   return true;
 }
 
s (#13325)' href='/ahoang/Nim/commit/tests/arc/tcontrolflow.nim?h=devel&id=fb641483f0e2ed974b89d629ea5ec28e5e6145ce'>fb641483f ^
42db75c97 ^













1854d2978 ^
42db75c97 ^
1854d2978 ^
42db75c97 ^





4d2ebbb87 ^
1854d2978 ^











cdce245a2 ^













ecf8cbbbe ^

06d776a58 ^










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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118