From 5bdc0334730a22182739aea96b2257ed42282614 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 27 Dec 2016 12:59:55 -0800 Subject: 3722 Bugfix: reinstate a check for missing types in 'get' instructions. Thanks Caleb Couch for running into this. --- 042name.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/042name.cc b/042name.cc index 48f2bfea..9be2b4da 100644 --- a/042name.cc +++ b/042name.cc @@ -251,8 +251,6 @@ if (inst.name == "get" || inst.name == "get-location" || inst.name == "put") { if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) { // since first non-address in base type must be a container, we don't have to canonize type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type); - if (base_type == -1) - break; // error raised elsewhere if (contains_key(Type, base_type)) { // otherwise we'll raise an error elsewhere inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); trace(9993, "name") << "element " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " is at offset " << no_scientific(inst.ingredients.at(1).value) << end(); @@ -260,6 +258,13 @@ if (inst.name == "get" || inst.name == "get-location" || inst.name == "put") { } } +:(scenario missing_type_in_get) +% Hide_errors = true; +def main [ + get a, x:offset +] ++error: main: missing type for 'a' in 'get a, x:offset' + //: this test is actually illegal so can't call run :(scenarios transform) :(scenario transform_names_handles_containers) @@ -296,11 +301,16 @@ if (inst.name == "maybe-convert") { if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) { // since first non-address in base type must be an exclusive container, we don't have to canonize type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type); - if (base_type == -1) - raise << maybe(get(Recipe, r).name) << "expected an exclusive-container in '" << inst.original_string << "'\n" << end(); if (contains_key(Type, base_type)) { // otherwise we'll raise an error elsewhere inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); trace(9993, "name") << "variant " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " has tag " << no_scientific(inst.ingredients.at(1).value) << end(); } } } + +:(scenario missing_type_in_maybe_convert) +% Hide_errors = true; +def main [ + maybe-convert a, x:variant +] ++error: main: missing type for 'a' in 'maybe-convert a, x:variant' -- cgit 1.4.1-2-gfad0 n1' href='#n1'>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