From d14bb91872dffdd1b9f3e40f68e42d50ea01bdef Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Mon, 2 Feb 2015 09:18:53 -0500 Subject: [PATCH] * more nuanced subs / slice error message * fixes ticket 913 --- source/be_rterror.c | 10 +++++++++- tests/t_c_deseq_func.d/control.err | 2 +- tests/t_c_deseq_seq.d/control.err | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/be_rterror.c b/source/be_rterror.c index 264dd6dd0..b361996f9 100644 --- a/source/be_rterror.c +++ b/source/be_rterror.c @@ -1271,7 +1271,15 @@ static void LookBackForSubscriptSymbol( intptr_t *pc, int sublevel, int has_slic } } else{ - snprintf(TPTempBuff, TPTEMP_BUFF_SIZE, " - in %s of desequencing operation", has_slice ? "slice/subscript" : "subscript" ); + if( *pc == rhs_subs || *pc == rhs_subs_check ){ + symtab_ptr assign_to = *(pc+3); + if( assign_to->name ){ + snprintf(TPTempBuff, TPTEMP_BUFF_SIZE, " - in assignment to '%s'", assign_to->name ); + sf_output( TPTempBuff ); + return; + } + } + snprintf(TPTempBuff, TPTEMP_BUFF_SIZE, " - in %s #%d", has_slice ? "slice/subscript" : "subscript", sublevel); sf_output( TPTempBuff ); } } diff --git a/tests/t_c_deseq_func.d/control.err b/tests/t_c_deseq_func.d/control.err index c22157c04..5779264a4 100644 --- a/tests/t_c_deseq_func.d/control.err +++ b/tests/t_c_deseq_func.d/control.err @@ -1,5 +1,5 @@ t_c_deseq_func.e:10 -subscript value 4 is out of bounds, reading from a sequence of length 3 - in subscript of desequencing operation +subscript value 4 is out of bounds, reading from a sequence of length 3 - in assignment to 'd' Public & Export & Global & Local Variables diff --git a/tests/t_c_deseq_seq.d/control.err b/tests/t_c_deseq_seq.d/control.err index 71e4c195a..a1fea0060 100644 --- a/tests/t_c_deseq_seq.d/control.err +++ b/tests/t_c_deseq_seq.d/control.err @@ -1,5 +1,5 @@ t_c_deseq_seq.e:4 -subscript value 1 is out of bounds, reading from a sequence of length 0 - in subscript of desequencing operation +subscript value 1 is out of bounds, reading from a sequence of length 0 - in assignment to 'a' Public & Export & Global & Local Variables