From e81da299fb49bd79cd460d477ec0bb673035620a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 20 Jul 2016 18:05:56 -0700 Subject: 3117 --- html/055shape_shifting_container.cc.html | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'html/055shape_shifting_container.cc.html') diff --git a/html/055shape_shifting_container.cc.html b/html/055shape_shifting_container.cc.html index abce7ede..fd9e9029 100644 --- a/html/055shape_shifting_container.cc.html +++ b/html/055shape_shifting_container.cc.html @@ -107,6 +107,13 @@ container foo:_b [ ] +error: headers of container 'foo' must use identical type ingredients +:(scenario type_ingredient_must_start_with_underscore) +% Hide_errors = true; +container foo:t [ + x:number +] ++error: foo: type ingredient 't' must begin with an underscore + :(before "End Globals") // We'll use large type ordinals to mean "the following type of the variable". // For example, if we have a generic type called foo:_elem, the type @@ -141,7 +148,7 @@ map<string, type_ordinal> type_ingredient_n istringstream in(save_name); name = slurp_until(in, ':'); map<string, type_ordinal> type_ingredient_names; - if (!slurp_type_ingredients(in, type_ingredient_names)) { + if (!slurp_type_ingredients(in, type_ingredient_names, name)) { return false; } if (contains_key(Type_ordinal, name) @@ -162,12 +169,20 @@ map<string, type_ordinal> type_ingredient_n return true; } -bool slurp_type_ingredients(istream& in, map<string, type_ordinal>& out) { +bool slurp_type_ingredients(istream& in, map<string, type_ordinal>& out, const string& container_name) { int next_type_ordinal = START_TYPE_INGREDIENTS; while (has_data(in)) { string curr = slurp_until(in, ':'); + if (curr.empty()) { + raise << container_name << ": empty type ingredients not permitted\n" << end(); + return false; + } + if (curr.at(0) != '_') { + raise << container_name << ": type ingredient '" << curr << "' must begin with an underscore\n" << end(); + return false; + } if (out.find(curr) != out.end()) { - raise << "can't repeat type ingredient names in a single container definition: '" << curr << "'\n" << end(); + raise << container_name << ": can't repeat type ingredient name'" << curr << "' in a single container definition\n" << end(); return false; } put(out, curr, next_type_ordinal++); -- cgit 1.4.1-2-gfad0