From 7f193a0e006c44604918b54c853bd49508dbe8fd Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 27 Nov 2015 18:10:15 -0800 Subject: 2482 - better choice between valid variants Literal '0' ingredients should map to numbers before addresses. --- 021check_instruction.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to '021check_instruction.cc') diff --git a/021check_instruction.cc b/021check_instruction.cc index f79ae140..930eacde 100644 --- a/021check_instruction.cc +++ b/021check_instruction.cc @@ -82,15 +82,19 @@ recipe main [ $error: 0 :(code) +bool types_match(const reagent& lhs, const reagent& rhs) { + if (!is_unsafe(rhs) && is_literal(rhs)) return valid_type_for_literal(lhs, rhs) && size_of(rhs) == size_of(lhs); + return types_strictly_match(lhs, rhs); +} + // copy arguments because later layers will want to make changes to them // without perturbing the caller -bool types_match(reagent lhs, reagent rhs) { +bool types_strictly_match(reagent lhs, reagent rhs) { // '_' never raises type error if (is_dummy(lhs)) return true; // to sidestep type-checking, use /unsafe in the source. // this will be highlighted in red inside vim. just for setting up some tests. if (is_unsafe(rhs)) return true; - 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); } -- cgit 1.4.1-2-gfad0