Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d1ffa46

Browse files
committed
Add error message if sep is not string
1 parent 21d486b commit d1ffa46

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,6 +3313,17 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
33133313
if (arg_name == "sep") {
33143314
visit_expr(*c->m_keywords[i].m_value);
33153315
separator = ASRUtils::EXPR(tmp);
3316+
ASR::ttype_t *type = ASRUtils::expr_type(separator);
3317+
if (!ASRUtils::is_character(*type)) {
3318+
std::string found = ASRUtils::type_to_str(type);
3319+
diag.add(diag::Diagnostic(
3320+
"Separator is expected to be of string type",
3321+
diag::Level::Error, diag::Stage::Semantic, {
3322+
diag::Label("Expected string, found: " + found,
3323+
{separator->base.loc})
3324+
})
3325+
);
3326+
}
33163327
break;
33173328
}
33183329
}

0 commit comments

Comments
 (0)