Skip to content

Commit

Permalink
nitc/engines: do not initialize optional attributes on the allocation
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Privat <[email protected]>
  • Loading branch information
privat committed May 4, 2016
1 parent 31ed461 commit 7b72022
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/compiler/abstract_compiler.nit
Original file line number Diff line number Diff line change
Expand Up @@ -3162,7 +3162,7 @@ redef class AAttrPropdef

fun init_expr(v: AbstractCompilerVisitor, recv: RuntimeVariable)
do
if has_value and not is_lazy and not n_expr isa ANullExpr then evaluate_expr(v, recv)
if has_value and not is_lazy and not is_optional and not n_expr isa ANullExpr then evaluate_expr(v, recv)
end

# Evaluate, store and return the default value of the attribute
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/naive_interpreter.nit
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ redef class AAttrPropdef
# Evaluate and set the default value of the attribute in `recv`
private fun init_expr(v: NaiveInterpreter, recv: Instance)
do
if is_lazy then return
if is_lazy or is_optional then return
if has_value then
var f = v.new_frame(self, mreadpropdef.as(not null), [recv])
evaluate_expr(v, recv, f)
Expand Down

0 comments on commit 7b72022

Please sign in to comment.