diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-04-15 17:40:12 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-04-15 17:40:12 -0700 |
commit | d785efe59c4b586763728b2a5574cf5fd8574f17 (patch) | |
tree | 633f94147f45c544a96828b41005dea791a0e48f /058shape_shifting_recipe.cc | |
parent | d31d70b60e6f136ad99274051ccbd494c4e6d058 (diff) | |
download | mu-d785efe59c4b586763728b2a5574cf5fd8574f17.tar.gz |
2836 - arcane bug in generic functions
Thanks Caleb Couch for finding and reporting this.
Diffstat (limited to '058shape_shifting_recipe.cc')
-rw-r--r-- | 058shape_shifting_recipe.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/058shape_shifting_recipe.cc b/058shape_shifting_recipe.cc index c892774d..0c48d596 100644 --- a/058shape_shifting_recipe.cc +++ b/058shape_shifting_recipe.cc @@ -401,6 +401,10 @@ void replace_type_ingredients(type_tree* type, const map<string, const type_tree const type_tree* replacement = get(mappings, type->name); trace(9993, "transform") << type->name << " => " << names_to_string(replacement) << end(); + if (!contains_key(Type_ordinal, replacement->name)) { + // error in program; should be reported elsewhere + return; + } // type is a single type ingredient assert(!type->left); @@ -984,3 +988,23 @@ def foo x:address:shared:_elem -> y:number [ ] # prefer the concrete variant, ignore concrete types in scoring the shape-shifting variant +mem: storing 34 in location 1 + +:(scenario missing_type_during_specialization) +% Hide_errors = true; +# define a shape-shifting recipe +def foo4 a:_elem [ +] +# define a container with field 'z' +container foo2 [ + z:number +] +def main [ + local-scope + x:foo2 <- merge 34 + y:number <- get x, z:offse # typo in 'offset' + # define a variable with the same name 'z' + z:number <- copy 34 + # trigger specialization of the shape-shifting recipe + foo4 z +] +# shouldn't crash |