Skip to content

Commit

Permalink
Unassigned instance variables should print 'nil'.
Browse files Browse the repository at this point in the history
  • Loading branch information
ltratt committed Jul 8, 2020
1 parent 05a5f46 commit 628948f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lang_tests/unassigned_inst_var.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"
VM:
status: success
stdout: nil
"

unassigned_inst_var = (
| x |
run = (
x println.
)
)
2 changes: 1 addition & 1 deletion src/lib/vm/objects/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Inst {
pub fn new(vm: &mut VM, class: Val) -> Val {
let cls: Gc<Class> = class.downcast(vm).unwrap();
let mut inst_vars = Vec::with_capacity(cls.num_inst_vars);
inst_vars.resize(cls.num_inst_vars, Val::illegal());
inst_vars.resize(cls.num_inst_vars, vm.nil);
let inst = Inst {
class,
inst_vars: UnsafeCell::new(inst_vars),
Expand Down

0 comments on commit 628948f

Please sign in to comment.