@@ -21,6 +21,7 @@ struct AttributeHandler {
21
21
{" int@bit_length" , &eval_int_bit_length},
22
22
{" list@append" , &eval_list_append},
23
23
{" list@remove" , &eval_list_remove},
24
+ {" list@clear" , &eval_list_clear},
24
25
{" list@insert" , &eval_list_insert},
25
26
{" list@pop" , &eval_list_pop},
26
27
{" set@pop" , &eval_set_pop},
@@ -187,6 +188,23 @@ struct AttributeHandler {
187
188
return make_ListPop_t (al, loc, s, idx, list_type, nullptr );
188
189
}
189
190
191
+ static ASR::asr_t * eval_list_clear (ASR::expr_t *s, Allocator &al,
192
+ const Location &loc, Vec<ASR::expr_t *> &args, diag::Diagnostics & diag) {
193
+ if (args.size () != 0 ) {
194
+ diag.add (diag::Diagnostic (
195
+ " Incorrect number of arguments in 'clear', it accepts no argument" ,
196
+ diag::Level::Error, diag::Stage::Semantic, {
197
+ diag::Label (" incorrect number of arguments in clear (found: " +
198
+ std::to_string (args.size ()) + " , expected: 0)" ,
199
+ {loc})
200
+ })
201
+ );
202
+ throw SemanticAbort ();
203
+ }
204
+
205
+ return make_ListClear_t (al, loc, s);
206
+ }
207
+
190
208
static ASR::asr_t * eval_set_pop (ASR::expr_t *s, Allocator &al, const Location &loc,
191
209
Vec<ASR::expr_t *> &args, diag::Diagnostics &/* diag*/ ) {
192
210
if (args.size () != 0 ) {
0 commit comments