diff --git a/src/Func.cpp b/src/Func.cpp index cc5b8bb5979c..ffb53632f658 100644 --- a/src/Func.cpp +++ b/src/Func.cpp @@ -1010,6 +1010,12 @@ void Stage::split(const string &old, const string &outer, const string &inner, c definition.schedule().touched() = true; + user_assert(inner != outer) << "In schedule for " << name() + << ", can't split " << old << " into " + << outer << " and " << inner + << " because the new Vars have the same name.\n" + << dump_argument_list(); + // Check that the new names aren't already in the dims list. for (auto &dim : dims) { string new_names[2] = {inner, outer}; diff --git a/test/error/CMakeLists.txt b/test/error/CMakeLists.txt index 95243a757cfd..f217d19534f0 100644 --- a/test/error/CMakeLists.txt +++ b/test/error/CMakeLists.txt @@ -91,6 +91,7 @@ tests(GROUPS error specialize_fail.cpp split_inner_wrong_tail_strategy.cpp split_non_innermost_predicated.cpp + split_same_var_names.cpp thread_id_outside_block_id.cpp too_many_args.cpp tuple_arg_select_undef.cpp diff --git a/test/error/split_same_var_names.cpp b/test/error/split_same_var_names.cpp new file mode 100644 index 000000000000..966427c471e4 --- /dev/null +++ b/test/error/split_same_var_names.cpp @@ -0,0 +1,13 @@ +#include "Halide.h" + +using namespace Halide; + +int main(int argc, char **argv) { + Var x; + Func f; + f(x) = x; + f.split(x, x, x, 16, TailStrategy::RoundUp); + + printf("Success!\n"); + return 0; +}