diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-11-08 10:31:48 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-11-08 10:31:48 -0800 |
commit | 4ecab1821ed7609d35f2c9509cb045dc79606e8c (patch) | |
tree | c5f7f3641fd24fac4c36139a81fcddd4dab188e5 /021check_instruction.cc | |
parent | f4647409b5fa658e463424c0a8249a4d72405d59 (diff) | |
download | mu-4ecab1821ed7609d35f2c9509cb045dc79606e8c.tar.gz |
3653
Don't crash on bad types. I need to be more careful in distinguishing between the two causes of constraint violations: bad input and internal bugs. Maybe I should create a second assert() to indicate "this shouldn't really be an assert, but I'm too lazy to think about it right now."
Diffstat (limited to '021check_instruction.cc')
-rw-r--r-- | 021check_instruction.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/021check_instruction.cc b/021check_instruction.cc index c049d619..93ce5427 100644 --- a/021check_instruction.cc +++ b/021check_instruction.cc @@ -176,7 +176,10 @@ bool is_mu_array(const type_tree* type) { if (!type) return false; if (is_literal(type)) return false; if (type->atom) return false; - assert(type->left->atom); + if (!type->left->atom) { + raise << "invalid type " << to_string(type) << '\n' << end(); + return false; + } return type->left->value == get(Type_ordinal, "array"); } @@ -188,7 +191,10 @@ bool is_mu_address(const type_tree* type) { if (!type) return false; if (is_literal(type)) return false; if (type->atom) return false; - assert(type->left->atom); + if (!type->left->atom) { + raise << "invalid type " << to_string(type) << '\n' << end(); + return false; + } return type->left->value == get(Type_ordinal, "address"); } |