diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-07-03 11:07:48 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-07-03 11:07:48 -0700 |
commit | 234ec878aa8c709dd61fb90f2556ff49da745ce0 (patch) | |
tree | fadc3dc8f30c49e4505654073ac98f0347fcea86 | |
parent | 3ef2f7dfe02837e9ce156cb668c29025d9d49f16 (diff) | |
download | mu-234ec878aa8c709dd61fb90f2556ff49da745ce0.tar.gz |
3095 - start type-checking 'deep-copy' instructions
-rw-r--r-- | 073deep_copy.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/073deep_copy.cc b/073deep_copy.cc index 02da9e68..277459e1 100644 --- a/073deep_copy.cc +++ b/073deep_copy.cc @@ -198,6 +198,14 @@ case DEEP_COPY: { raise << maybe(get(Recipe, r).name) << "'deep-copy' takes exactly one ingredient rather than '" << to_original_string(inst) << "'\n" << end(); break; } + if (SIZE(inst.products) != 1) { + raise << maybe(get(Recipe, r).name) << "'deep-copy' takes exactly one ingredient rather than '" << to_original_string(inst) << "'\n" << end(); + break; + } + if (!types_strictly_match(inst.ingredients.at(0), inst.products.at(0))) { + raise << maybe(get(Recipe, r).name) << "'deep-copy' requires its ingredient and product to be the same type, but got '" << to_original_string(inst) << "'\n" << end(); + break; + } break; } :(before "End Primitive Recipe Implementations") |