Skip to content

Commit

Permalink
Merge #169
Browse files Browse the repository at this point in the history
169: Unassigned instance variables should print 'nil'. r=vext01 a=ltratt



Co-authored-by: Laurence Tratt <[email protected]>
  • Loading branch information
bors[bot] and ltratt authored Jul 8, 2020
2 parents 05a5f46 + 628948f commit b6f238b
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 b6f238b

Please sign in to comment.