Allow const property initialization in nested constructor blocks
A named block inside a class constructor has its own scope. The const property assignment check currently tests the name of this immediate scope and rejects the assignment because it is not named `new` or `new@`. Find the containing class method before deciding whether the assignment is in the constructor. Assignments from nested blocks in other methods remain invalid. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
bfc0121fb9
commit
14066871e5
|
|
@ -1137,13 +1137,16 @@ NetAssign_* PEIdent::elaborate_lval_net_class_member_(Design*des, NetScope*scope
|
|||
return lv;
|
||||
|
||||
} else if (qual.test_const()) {
|
||||
auto method_scope = find_method_containing_scope(*this, scope);
|
||||
if (class_type->get_prop_initialized(pidx)) {
|
||||
cerr << get_fileline() << ": error: "
|
||||
<< "Property " << class_type->get_prop_name(pidx)
|
||||
<< " is constant in this method."
|
||||
<< " (scope=" << scope_path(scope) << ")" << endl;
|
||||
des->errors++;
|
||||
} else if (scope->basename() != "new" && scope->basename() != "new@") {
|
||||
} else if (!method_scope ||
|
||||
(method_scope->basename() != "new" &&
|
||||
method_scope->basename() != "new@")) {
|
||||
cerr << get_fileline() << ": error: "
|
||||
<< "Property " << class_type->get_prop_name(pidx)
|
||||
<< " is constant in this method."
|
||||
|
|
|
|||
Loading…
Reference in New Issue