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

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4493,6 +4493,10 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
int64_t inc_int = 1;
bool is_value_present = ASRUtils::extract_value(inc_value, inc_int);
if (is_value_present) {
if (inc_int == 0) {
throw SemanticError("For loop increment should not be zero.", loc);
}

// Loop end depends upon the sign of m_increment.
// if inc > 0 then: loop_end -=1 else loop_end += 1
ASR::binopType offset_op;
Expand Down