@@ -71,11 +71,19 @@ namespace Sass {
7171 bool empty = m ? m->empty () : sl->empty ();
7272 if (empty) error (" argument `$list` of `" + std::string (sig) + " ` must not be empty" , pstate, traces);
7373 double index = std::floor (nr < 0 ? len + nr : nr - 1 );
74- if (index < 0 || index > len - 1 ) error (" index out of bounds for `" + std::string (sig) + " `" , pstate, traces);
74+ if (index < 0 || index > len - 1 ) {
75+ if (index == -1 ) error (" $n: List index may not be 0." , pstate, traces);
76+ std::stringstream strm;
77+ strm << " $n: Invalid index " ;
78+ strm << (index + 1 );
79+ strm << " for a list with " ;
80+ strm << len << " elements." ;
81+ error (strm.str (), pstate, traces);
82+ }
7583 return Cast<Value>(Listize::perform (sl->get (static_cast <int >(index))));
7684 }
7785 List_Obj l = Cast<List>(env[" $list" ]);
78- if (nr == 0 ) error (" argument `$n` of ` " + std::string (sig) + " ` must be non-zero " , pstate, traces);
86+ if (nr == 0 ) error (" $n: List index may not be 0. " , pstate, traces);
7987 // if the argument isn't a list, then wrap it in a singleton list
8088 if (!m && !l) {
8189 l = SASS_MEMORY_NEW (List, pstate, 1 );
@@ -85,7 +93,15 @@ namespace Sass {
8593 bool empty = m ? m->empty () : l->empty ();
8694 if (empty) error (" argument `$list` of `" + std::string (sig) + " ` must not be empty" , pstate, traces);
8795 double index = std::floor (nr < 0 ? len + nr : nr - 1 );
88- if (index < 0 || index > len - 1 ) error (" index out of bounds for `" + std::string (sig) + " `" , pstate, traces);
96+ if (index < 0 || index > len - 1 ) {
97+ if (index == -1 ) error (" $n: List index may not be 0." , pstate, traces);
98+ std::stringstream strm;
99+ strm << " $n: Invalid index " ;
100+ strm << (index + 1 );
101+ strm << " for a list with " ;
102+ strm << l->length () << " elements." ;
103+ error (strm.str (), pstate, traces);
104+ }
89105
90106 if (m) {
91107 l = SASS_MEMORY_NEW (List, pstate, 2 );
@@ -116,7 +132,15 @@ namespace Sass {
116132 }
117133 if (l->empty ()) error (" argument `$list` of `" + std::string (sig) + " ` must not be empty" , pstate, traces);
118134 double index = std::floor (n->value () < 0 ? l->length () + n->value () : n->value () - 1 );
119- if (index < 0 || index > l->length () - 1 ) error (" index out of bounds for `" + std::string (sig) + " `" , pstate, traces);
135+ if (index < 0 || index > l->length () - 1 ) {
136+ if (index == -1 ) error (" $n: List index may not be 0." , pstate, traces);
137+ std::stringstream strm;
138+ strm << " $n: Invalid index " ;
139+ strm << (index + 1 );
140+ strm << " for a list with " ;
141+ strm << l->length () << " elements." ;
142+ error (strm.str (), pstate, traces);
143+ }
120144 List* result = SASS_MEMORY_NEW (List, pstate, l->length (), l->separator (), false , l->is_bracketed ());
121145 for (size_t i = 0 , L = l->length (); i < L; ++i) {
122146 result->append (((i == index) ? v : (*l)[i]));
@@ -181,7 +205,7 @@ namespace Sass {
181205 std::string sep_str = unquote (sep->value ());
182206 if (sep_str == " space" ) sep_val = SASS_SPACE;
183207 else if (sep_str == " comma" ) sep_val = SASS_COMMA;
184- else if (sep_str != " auto" ) error (" argument ` $separator` of ` " + std::string (sig) + " ` must be ` space`, ` comma` , or ` auto` " , pstate, traces);
208+ else if (sep_str != " auto" ) error (" $separator: Must be \" space\" , \" comma\" , or \" auto\" . " , pstate, traces);
185209
186210 if (l1) { l1sep = l1->separator (); }
187211 if (l2) { l2sep = l2->separator (); }
@@ -242,7 +266,7 @@ namespace Sass {
242266 if (sep_str != " auto" ) { // check default first
243267 if (sep_str == " space" ) result->separator (SASS_SPACE);
244268 else if (sep_str == " comma" ) result->separator (SASS_COMMA);
245- else error (" argument ` $separator` of ` " + std::string (sig) + " ` must be ` space`, ` comma` , or ` auto` " , pstate, traces);
269+ else error (" $separator: Must be \" space\" , \" comma\" , or \" auto\" . " , pstate, traces);
246270 }
247271 if (l->is_arglist ()) {
248272 result->append (SASS_MEMORY_NEW (Argument,
0 commit comments