mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Make const variables actually constant. Addresses #922.
Both local and global variables declared with "const" could be modified, but now expressions that would modify them should generate an error message at parse-time.
This commit is contained in:
parent
6603b851fe
commit
290c2a0b4d
9 changed files with 120 additions and 10 deletions
|
@ -210,7 +210,6 @@ static void make_var(ID* id, BroType* t, init_class c, Expr* init,
|
|||
// defined.
|
||||
Func* f = new BroFunc(id, 0, 0, 0, 0);
|
||||
id->SetVal(new Val(f));
|
||||
id->SetConst();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,8 +232,9 @@ Stmt* add_local(ID* id, BroType* t, init_class c, Expr* init,
|
|||
|
||||
Ref(id);
|
||||
|
||||
Expr* name_expr = new NameExpr(id, dt == VAR_CONST);
|
||||
Stmt* stmt =
|
||||
new ExprStmt(new AssignExpr(new NameExpr(id), init, 0, 0,
|
||||
new ExprStmt(new AssignExpr(name_expr, init, 0, 0,
|
||||
id->Attrs() ? id->Attrs()->Attrs() : 0 ));
|
||||
stmt->SetLocationInfo(init->GetLocationInfo());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue