Skip to content
Prev Previous commit
Next Next commit
Handle modifying attribute on a compile time value
  • Loading branch information
kmr-srbh committed May 1, 2024
commit 94062cc007f429af41c4f1b292c396f1f076995c
16 changes: 9 additions & 7 deletions src/lpython/semantics/python_attribute_eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ struct AttributeHandler {
throw SemanticError("Type name is not implemented yet.", loc);
}
std::string key = class_name + "@" + attr_name;
// if (modify_attr_set.find(key) != modify_attr_set.end()) {
// ASR::Variable_t* v = ASRUtils::EXPR2VAR(e);
// if (v->m_intent == ASRUtils::intent_in) {
// throw SemanticError("Modifying input function parameter `"
// + std::string(v->m_name) + "` is not allowed", loc);
// }
// }
if (modify_attr_set.find(key) != modify_attr_set.end()) {
if (ASR::is_a<ASR::Var_t>(*e)) {
ASR::Variable_t* v = ASRUtils::EXPR2VAR(e);
if (v->m_intent == ASRUtils::intent_in) {
throw SemanticError("Modifying input function parameter `"
+ std::string(v->m_name) + "` is not allowed", loc);
}
}
}
auto search = attribute_map.find(key);
if (search != attribute_map.end()) {
attribute_eval_callback cb = search->second;
Expand Down