From c91caafd5bd5dae25b0e0efa19879258ff61ad93 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 28 Jul 2015 19:33:19 -0700 Subject: 1879 - types required at first mention of a name That should avoid many issues with typos in names. --- 020run.cc | 4 +++- 032array.cc | 2 +- 048typecheck.cc | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/020run.cc b/020run.cc index 81eeb14d..be144858 100644 --- a/020run.cc +++ b/020run.cc @@ -212,7 +212,7 @@ void write_memory(reagent x, vector data) { if (is_literal(x)) return; long long int base = x.value; if (size_mismatch(x, data)) { - raise << current_recipe_name() << ": size mismatch in storing to " << x.to_string() << " at " << current_instruction().to_string() << '\n' << end(); + raise << current_recipe_name() << ": size mismatch in storing to " << x.original_string << " at '" << current_instruction().to_string() << "'\n" << end(); return; } for (long long int offset = 0; offset < SIZE(data); ++offset) { @@ -234,6 +234,8 @@ long long int size_of(const vector& types) { } bool size_mismatch(const reagent& x, const vector& data) { + if (x.types.empty()) return true; + // End size_mismatch(x) Cases //? if (size_of(x) != SIZE(data)) cerr << size_of(x) << " vs " << SIZE(data) << '\n'; //? 2 return size_of(x) != SIZE(data); } diff --git a/032array.cc b/032array.cc index dc8c04a5..d00f5939 100644 --- a/032array.cc +++ b/032array.cc @@ -38,7 +38,7 @@ recipe main [ +mem: storing 16 in location 9 //: disable the size mismatch check since the destination array need not be initialized -:(after "bool size_mismatch(const reagent& x, const vector& data)") +:(before "End size_mismatch(x) Cases") if (x.types.at(0) == Type_ordinal["array"]) return false; :(before "End size_of(reagent) Cases") if (r.types.at(0) == Type_ordinal["array"]) { diff --git a/048typecheck.cc b/048typecheck.cc index 46225f94..f686f78f 100644 --- a/048typecheck.cc +++ b/048typecheck.cc @@ -67,3 +67,13 @@ recipe main [ x <- add x, 1 ] +mem: storing 2 in location 1 + +:(scenario transform_warns_on_missing_types_in_first_mention) +% Hide_warnings = true; +recipe main [ + x <- copy 1 + x:number <- copy 2 +] ++warn: missing type in 'x <- copy 1' ++warn: x <- copy 1: reagent not initialized: x ++warn: main: size mismatch in storing to x at 'x <- copy 1' -- cgit 1.4.1-2-gfad0 in&id=7282b475ae6a97b8cea3e6b7681bc333a8b5c878'>root/help
blob: 656b2afc13b70faa268e50cd3df3418526fa4c0c (plain) (tree)
1
2
3
4