diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-15 01:02:53 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-15 01:02:53 -0800 |
commit | 687dd3f5da63bee9dd310bc4ac2844ece43e3fba (patch) | |
tree | 3e57d03f17a59c97a9ba10b15ee87084eced66e1 /021check_instruction.cc | |
parent | ef96f57ce264c8e0bd98f6e8622d1c1e2eceafb2 (diff) | |
download | mu-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.cc | 11 |
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; } |