@@ -71,11 +71,19 @@ namespace Sass {
71
71
bool empty = m ? m->empty () : sl->empty ();
72
72
if (empty) error (" argument `$list` of `" + std::string (sig) + " ` must not be empty" , pstate, traces);
73
73
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
+ }
75
83
return Cast<Value>(Listize::perform (sl->get (static_cast <int >(index ))));
76
84
}
77
85
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);
79
87
// if the argument isn't a list, then wrap it in a singleton list
80
88
if (!m && !l) {
81
89
l = SASS_MEMORY_NEW (List, pstate, 1 );
@@ -85,7 +93,15 @@ namespace Sass {
85
93
bool empty = m ? m->empty () : l->empty ();
86
94
if (empty) error (" argument `$list` of `" + std::string (sig) + " ` must not be empty" , pstate, traces);
87
95
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
+ }
89
105
90
106
if (m) {
91
107
l = SASS_MEMORY_NEW (List, pstate, 2 );
@@ -116,7 +132,15 @@ namespace Sass {
116
132
}
117
133
if (l->empty ()) error (" argument `$list` of `" + std::string (sig) + " ` must not be empty" , pstate, traces);
118
134
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
+ }
120
144
List* result = SASS_MEMORY_NEW (List, pstate, l->length (), l->separator (), false , l->is_bracketed ());
121
145
for (size_t i = 0 , L = l->length (); i < L; ++i) {
122
146
result->append (((i == index ) ? v : (*l)[i]));
@@ -181,7 +205,7 @@ namespace Sass {
181
205
std::string sep_str = unquote (sep->value ());
182
206
if (sep_str == " space" ) sep_val = SASS_SPACE;
183
207
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);
185
209
186
210
if (l1) { l1sep = l1->separator (); }
187
211
if (l2) { l2sep = l2->separator (); }
@@ -242,7 +266,7 @@ namespace Sass {
242
266
if (sep_str != " auto" ) { // check default first
243
267
if (sep_str == " space" ) result->separator (SASS_SPACE);
244
268
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);
246
270
}
247
271
if (l->is_arglist ()) {
248
272
result->append (SASS_MEMORY_NEW (Argument,
0 commit comments