diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-26 12:53:15 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-26 12:53:15 +0800 |
commit | 04f2da9e198abf8e96cd3abb3782f2bfeae3c8f5 (patch) | |
tree | c77a4289a9629a79710114b4046208d3f1f12582 /src/macro_rules | |
parent | 942f7025ce5c1e24330d001cd350c4fc0712a560 (diff) | |
download | mrust-04f2da9e198abf8e96cd3abb3782f2bfeae3c8f5.tar.gz |
macro_rules - Don't loop if a variable is missing data
Diffstat (limited to 'src/macro_rules')
-rw-r--r-- | src/macro_rules/eval.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/macro_rules/eval.cpp b/src/macro_rules/eval.cpp index 95d7c2d2..c6dfd72e 100644 --- a/src/macro_rules/eval.cpp +++ b/src/macro_rules/eval.cpp @@ -964,10 +964,16 @@ const MacroExpansionEnt* MacroExpandState::next_ent() unsigned int num_repeats = 0; for(const auto idx : e.variables) { unsigned int this_repeats = m_mappings.count_in(m_iterations, idx); + // If a variable doesn't have data, don't loop + if( this_repeats == 0 ) { + num_repeats = 0; + break; + } + // TODO: Ideally, all variables would have the same repeat count. if( this_repeats > num_repeats ) num_repeats = this_repeats; } - DEBUG("Looping " << num_repeats << " times"); + DEBUG("Looping " << num_repeats << " times based on {" << e.variables << "}"); // 2. If it's going to repeat, start the loop if( num_repeats > 0 ) { |