Open
Description
Reading of uninitialized variables in methods is likely broken. At least it is in SOMns.
The following test fails with an assertion, because the read evaluates to null
:
class Test usingPlatform: platform = Value ()(
protected foo = (
| a |
a println.
a := 1.
a println.
)
public main: args = (
foo.
foo.
^ 0
)
)
A fix could be:
diff --git a/src/som/compiler/MethodBuilder.java b/src/som/compiler/MethodBuilder.java
index 1598a2b..20e8757 100644
--- a/src/som/compiler/MethodBuilder.java
+++ b/src/som/compiler/MethodBuilder.java
@@ -101,7 +102,8 @@ public final class MethodBuilder {
MethodScope outer = (outerBuilder != null)
? outerBuilder.getCurrentMethodScope()
: null;
- this.currentScope = new MethodScope(new FrameDescriptor(), outer, clsScope);
+ assert Nil.nilObject != null;
+ this.currentScope = new MethodScope(new FrameDescriptor(Nil.nilObject), outer, clsScope);
accessesVariablesOfOuterScope = false;
throwsNonLocalReturn = false;
/cc @charig