nullable: enforce static and dynamic rules.
authorJean Privat <jean@pryen.org>
Thu, 25 Jun 2009 20:29:26 +0000 (16:29 -0400)
committerJean Privat <jean@pryen.org>
Fri, 26 Jun 2009 05:06:51 +0000 (01:06 -0400)
Switch warnings to errors.
Update tests to let them not produce errors. Note that:
 * base_nullable.nit have new error cases
 * test_isa.nit add some test cases
 * test_nil.nit is removed since it is to much outdated.

Signed-off-by: Jean Privat <jean@pryen.org>

45 files changed:
src/compiling/compiling_global.nit
src/compiling/compiling_methods.nit
src/syntax/syntax_base.nit
tests/base_closure6.nit
tests/base_isa_nil.nit
tests/base_virtual_type.nit
tests/base_virtual_type2.nit
tests/base_virtual_type3.nit
tests/base_virtual_type7.nit
tests/bench_netsim.nit
tests/bench_send.nit
tests/example_objet.nit
tests/sav/base_attr_nullable_alt1.sav
tests/sav/base_attr_nullable_alt2.sav
tests/sav/base_attr_nullable_alt3.sav
tests/sav/base_attr_nullable_alt4.sav
tests/sav/base_attr_nullable_alt5.sav
tests/sav/base_attr_nullable_int_alt1.sav
tests/sav/base_attr_nullable_int_alt2.sav
tests/sav/base_attr_nullable_int_alt3.sav
tests/sav/base_attr_nullable_int_alt4.sav
tests/sav/base_attr_nullable_int_alt5.sav
tests/sav/base_isa_nil.sav
tests/sav/base_nullable_alt1.sav
tests/sav/base_nullable_alt10.sav [new file with mode: 0644]
tests/sav/base_nullable_alt6.sav
tests/sav/base_nullable_alt7.sav
tests/sav/base_nullable_alt9.sav [new file with mode: 0644]
tests/sav/base_virtual_type2_alt1.sav
tests/sav/base_virtual_type4_alt1.sav
tests/sav/base_virtual_type5_alt1.sav
tests/sav/base_virtual_type5_alt2.sav
tests/sav/base_virtual_type_alt1.sav
tests/sav/base_virtual_type_alt2.sav
tests/sav/base_virtual_type_alt3.sav
tests/sav/test_nil.sav [deleted file]
tests/shootout_binarytrees.nit
tests/test_create_more.nit
tests/test_eq.nit
tests/test_equal_nil.nit
tests/test_gen_inh.nit
tests/test_isa.nit
tests/test_nil.nit [deleted file]
tests/test_undead.nit
tests/test_variance_attr.nit

index 96837be..d2a4616 100644 (file)
@@ -912,8 +912,8 @@ redef class MMLocalClass
                        for g in global_properties do
                                var p = self[g]
                                var t = p.signature.return_type
-                               if p isa MMAttribute and t != null and not t.is_nullable and v.tc.opt_warn.value > 0 then
-                                       v.add_instr("if ({p.global.attr_access}(self) == NIT_NULL) fprintf(stderr, \"Uninitialized attribute %s at %s.\\n\", \"{p.full_name}\", from);")
+                               if p isa MMAttribute and t != null and not t.is_nullable then
+                                       v.add_instr("if ({p.global.attr_access}(self) == NIT_NULL) \{ fprintf(stderr, \"Uninitialized attribute %s at %s.\\n\", \"{p.full_name}\", from); nit_exit(1); \}")
                                end
                        end
                        ctx_old.append(v.ctx)
index 65c05b3..badeaa4 100644 (file)
@@ -464,9 +464,9 @@ redef class MMAttribute
        meth compile_read_access(v: CompilerVisitor, n: PNode, recv: String): String
        do
                var res = "{global.attr_access}({recv}) /*{local_class}::{name}*/"
-               if not signature.return_type.is_nullable and v.tc.opt_warn.value > 0 then
+               if not signature.return_type.is_nullable then
                        res = v.ensure_var(res, "{local_class}::{name}")
-                       v.add_instr("if ({res} == NIT_NULL) \{ fprintf(stderr, \"Uninitialized attribute %s\", \"{name}\"); {v.printf_locate_error(n)} } /* implicit isset */;")
+                       v.add_instr("if ({res} == NIT_NULL) \{ fprintf(stderr, \"Uninitialized attribute %s\", \"{name}\"); {v.printf_locate_error(n)} nit_exit(1); } /* implicit isset */;")
                end
                return res
        end
index 21cfba4..34b096d 100644 (file)
@@ -362,11 +362,6 @@ special Visitor
                if subtype < stype  then
                        return true
                end
-               # Do not enforce nullable subtype rules yet
-               if subtype isa MMTypeNone or subtype.as_notnull < stype.as_notnull then
-                       warning(n, "Nullable type warning: expected {stype}, got {subtype}")
-                       return true
-               end
                error(n, "Type error: expected {stype}, got {subtype}")
                return false
        end
index 53a6e0d..48e99cc 100644 (file)
@@ -20,7 +20,7 @@ class A
        meth foo: U
                with bar
        do
-               return null
+               return new U
        end
 end
 
index a862583..2fea00e 100644 (file)
@@ -32,7 +32,13 @@ var b: Object = new B
 (a isa A).output
 (a isa Object).output
 (not a isa B).output
-var c: Object = null
+(a isa nullable A).output
+(a isa nullable Object).output
+(not a isa nullable B).output
+var c: nullable Object = null
 (c isa A).output
 (c isa Object).output
 (c isa B).output
+(c isa nullable A).output
+(c isa nullable Object).output
+(c isa nullable B).output
index 23a4b2b..87dec55 100644 (file)
@@ -19,7 +19,7 @@ import kernel
 class A
        type E: T
        
-       readable writable attr _e: E = null
+       readable writable attr _e: nullable E = null 
 end
 
 class B
index e20f497..a5cfaf9 100644 (file)
@@ -19,7 +19,7 @@ import kernel
 class A
        type E: T
        
-       readable writable attr _e: E = null
+       readable writable attr _e: nullable E = null
 end
 
 class B
@@ -39,8 +39,8 @@ special T
 end
 
 var b = new B
-var t: T
-var u = new U
+var t: nullable T
+var u: nullable U = new U
 
 b.e = u
 #alt1#u = b.e
index 0f33aa8..f66f1fa 100644 (file)
@@ -19,7 +19,7 @@ import array
 
 class C
 special A
-       readable writable attr _tab: Array[E]
+       readable writable attr _tab: nullable Array[E]
        init do end
 end
 
index f426cab..6587249 100644 (file)
@@ -19,7 +19,7 @@ import kernel
 class A
        type E: F
        type F: E
-       readable writable attr _e: E
+       readable writable attr _e: nullable E = null
        init do end
 end
 
index f11554b..ffc0f3c 100644 (file)
@@ -19,7 +19,7 @@ class Node
        do
                return _name
        end
-       attr _name: String = null
+       attr _name: String = "noname"
 end
 
 class WakeUpNode
@@ -31,12 +31,12 @@ special Node
        do
                _scheduler.add_event(self, d)
        end
-       attr _scheduler: Scheduler = null
+       attr _scheduler: Scheduler
 end
 
 class NodeSource
 special Node
-       attr _nexts: ArraySet[NodeSink] = null
+       attr _nexts: nullable ArraySet[NodeSink] = null
        meth attach(n: NodeSink)
        # Add the sink `n' the the connected nodes
        # Do nothing if `n' is already connected
@@ -63,7 +63,7 @@ special Node
                if _nexts == null then
                        return
                end
-               for n in _nexts do
+               for n in _nexts.as(not null) do
                        n.recieve(self)
                end
        end
@@ -78,7 +78,7 @@ end
 #
 
 class Scheduler
-       attr _time_list: Array[Couple[Int, WakeUpNode]]
+       attr _time_list: Array[Couple[Int, WakeUpNode]] = new Array[Couple[Int, WakeUpNode]]
        attr _time: Int = 0 # What time is it ?
        meth add_event(n: WakeUpNode, d: Int)
        # The node `n' whant to be weaked up in `d' time units
@@ -87,7 +87,7 @@ class Scheduler
                _time_list.add(entry)
        end
 
-       meth next_event: WakeUpNode
+       meth next_event: nullable WakeUpNode
        # Get the
        do
                if _time_list.is_empty then
@@ -125,7 +125,6 @@ class Scheduler
 
        init
        do
-               _time_list = new Array[Couple[Int, WakeUpNode]]
        end
 end
 
@@ -174,7 +173,7 @@ end
 class NodeAlternate
 special NodeSink
 special NodeSource
-       attr _last: NodeSource
+       attr _last: nullable NodeSource
        redef meth recieve(n: NodeSource)
        do
                if n != _last then
index e3ee5ee..ee546c9 100644 (file)
@@ -16,7 +16,7 @@
 
 
 class A
-       readable writable attr _val: Int
+       readable writable attr _val: Int = 0
        meth hop(a: A, b: A, c: A)
        do
                if a.val > val then
index cc22a7c..cc67246 100644 (file)
@@ -208,8 +208,8 @@ end
 
 class Rayon
 private
-       attr _stock: Array[Produit] = null      # Des produits en stock
-       attr _rubrique: String = null           # La catégorie des produits stockés
+       attr _stock: Array[Produit]             # Des produits en stock
+       attr _rubrique: String                  # La catégorie des produits stockés
 
        # Cette fonction est utilisé par to_s pour afficher un petit titre
        meth to_s_head: String
@@ -227,7 +227,7 @@ private
                return s.to_s
        end
 
-       meth cherche_produit(n: String): Produit
+       meth cherche_produit(n: String): nullable Produit
        do
                var i = _stock.iterator
                while i.is_ok do
@@ -300,6 +300,8 @@ private
        # pour obtenir la quantité de clous dans le rayon, et :
        #       r.quantite("clous") = 15
        # pour mettre le nombre de clous Ã  15
+
+       init do end
 end
 
 class RayonNormal
index 7f93cf3..ca81b10 100644 (file)
@@ -1,4 +1,4 @@
-Recieved signal 11
+Uninitialized attribute _a1 in base_attr_nullable_alt1::Foo::run (alt/base_attr_nullable_alt1.nit:38)
 ,---- Stack trace -- - -  -
 | base_attr_nullable_alt1::Foo::run (alt/base_attr_nullable_alt1.nit:36)
 | base_attr_nullable_alt1::Foo::init (alt/base_attr_nullable_alt1.nit:48)
index 450ae77..999e869 100644 (file)
@@ -1,6 +1,7 @@
 1
-Recieved signal 11
+Uninitialized attribute _a2 (alt/base_attr_nullable_alt2.nit:35)
 ,---- Stack trace -- - -  -
+| base_attr_nullable_alt2::Foo::a2 (alt/base_attr_nullable_alt2.nit:35)
 | base_attr_nullable_alt2::Foo::run (alt/base_attr_nullable_alt2.nit:36)
 | base_attr_nullable_alt2::Foo::init (alt/base_attr_nullable_alt2.nit:48)
 | base_attr_nullable_alt2::Sys::main (alt/base_attr_nullable_alt2.nit:81)
index 4face12..0ee9fff 100644 (file)
@@ -1,4 +1,4 @@
-Recieved signal 11
+Uninitialized attribute _a1 in base_attr_nullable_alt3::Bar::(base_attr_nullable_alt3::Foo::run) (alt/base_attr_nullable_alt3.nit:64)
 ,---- Stack trace -- - -  -
 | base_attr_nullable_alt3::Bar::(base_attr_nullable_alt3::Foo::run) (alt/base_attr_nullable_alt3.nit:62)
 | base_attr_nullable_alt3::Bar::init (alt/base_attr_nullable_alt3.nit:69)
index 2c29f07..2a4dd60 100644 (file)
@@ -1,5 +1,5 @@
 10
-Recieved signal 11
+Uninitialized attribute _a2 in base_attr_nullable_alt4::Foo::run_other (alt/base_attr_nullable_alt4.nit:45)
 ,---- Stack trace -- - -  -
 | base_attr_nullable_alt4::Foo::run_other (alt/base_attr_nullable_alt4.nit:42)
 | base_attr_nullable_alt4::Bar::init (alt/base_attr_nullable_alt4.nit:69)
index 961ad0d..07bfb3c 100644 (file)
@@ -1,6 +1,6 @@
 10
 20
-Recieved signal 11
+Uninitialized attribute _a3 in base_attr_nullable_alt5::Bar::(base_attr_nullable_alt5::Foo::run) (alt/base_attr_nullable_alt5.nit:66)
 ,---- Stack trace -- - -  -
 | base_attr_nullable_alt5::Bar::(base_attr_nullable_alt5::Foo::run) (alt/base_attr_nullable_alt5.nit:62)
 | base_attr_nullable_alt5::Bar::init (alt/base_attr_nullable_alt5.nit:69)
index 5625f1f..c8d5ccf 100644 (file)
@@ -1,7 +1,6 @@
-0
-0
-1
-2
-10
-20
-30
+Uninitialized attribute _a1 in base_attr_nullable_int_alt1::Foo::run (alt/base_attr_nullable_int_alt1.nit:32)
+,---- Stack trace -- - -  -
+| base_attr_nullable_int_alt1::Foo::run (alt/base_attr_nullable_int_alt1.nit:30)
+| base_attr_nullable_int_alt1::Foo::init (alt/base_attr_nullable_int_alt1.nit:42)
+| base_attr_nullable_int_alt1::Sys::main (alt/base_attr_nullable_int_alt1.nit:75)
+`------------------- - -  -
index 2e8046c..61a7d03 100644 (file)
@@ -1,7 +1,8 @@
 1
-0
-1
-2
-10
-20
-30
+Uninitialized attribute _a2 (alt/base_attr_nullable_int_alt2.nit:29)
+,---- Stack trace -- - -  -
+| base_attr_nullable_int_alt2::Foo::a2 (alt/base_attr_nullable_int_alt2.nit:29)
+| base_attr_nullable_int_alt2::Foo::run (alt/base_attr_nullable_int_alt2.nit:30)
+| base_attr_nullable_int_alt2::Foo::init (alt/base_attr_nullable_int_alt2.nit:42)
+| base_attr_nullable_int_alt2::Sys::main (alt/base_attr_nullable_int_alt2.nit:75)
+`------------------- - -  -
index f0c5f8f..7587dfd 100644 (file)
@@ -1,8 +1,6 @@
-0
-0
-0
-1
-2
-10
-20
-30
+Uninitialized attribute _a1 in base_attr_nullable_int_alt3::Bar::(base_attr_nullable_int_alt3::Foo::run) (alt/base_attr_nullable_int_alt3.nit:58)
+,---- Stack trace -- - -  -
+| base_attr_nullable_int_alt3::Bar::(base_attr_nullable_int_alt3::Foo::run) (alt/base_attr_nullable_int_alt3.nit:56)
+| base_attr_nullable_int_alt3::Bar::init (alt/base_attr_nullable_int_alt3.nit:63)
+| base_attr_nullable_int_alt3::Sys::main (alt/base_attr_nullable_int_alt3.nit:75)
+`------------------- - -  -
index a12c8e0..7880ac1 100644 (file)
@@ -1,7 +1,7 @@
 10
-0
-1
-2
-10
-20
-30
+Uninitialized attribute _a2 in base_attr_nullable_int_alt4::Foo::run_other (alt/base_attr_nullable_int_alt4.nit:39)
+,---- Stack trace -- - -  -
+| base_attr_nullable_int_alt4::Foo::run_other (alt/base_attr_nullable_int_alt4.nit:36)
+| base_attr_nullable_int_alt4::Bar::init (alt/base_attr_nullable_int_alt4.nit:63)
+| base_attr_nullable_int_alt4::Sys::main (alt/base_attr_nullable_int_alt4.nit:75)
+`------------------- - -  -
index f343f0e..cbe4cde 100644 (file)
@@ -1,8 +1,8 @@
 10
 20
-0
-1
-2
-10
-20
-30
+Uninitialized attribute _a3 in base_attr_nullable_int_alt5::Bar::(base_attr_nullable_int_alt5::Foo::run) (alt/base_attr_nullable_int_alt5.nit:60)
+,---- Stack trace -- - -  -
+| base_attr_nullable_int_alt5::Bar::(base_attr_nullable_int_alt5::Foo::run) (alt/base_attr_nullable_int_alt5.nit:56)
+| base_attr_nullable_int_alt5::Bar::init (alt/base_attr_nullable_int_alt5.nit:63)
+| base_attr_nullable_int_alt5::Sys::main (alt/base_attr_nullable_int_alt5.nit:75)
+`------------------- - -  -
index 5ec39bb..a9c7347 100644 (file)
@@ -4,3 +4,9 @@ true
 true
 true
 true
+false
+false
+false
+true
+true
+true
index e69de29..8b219cf 100644 (file)
@@ -0,0 +1 @@
+alt/base_nullable_alt1.nit:36,13--14: Type error: expected A, got nullable A
diff --git a/tests/sav/base_nullable_alt10.sav b/tests/sav/base_nullable_alt10.sav
new file mode 100644 (file)
index 0000000..db447d6
--- /dev/null
@@ -0,0 +1 @@
+alt/base_nullable_alt10.nit:55,18--21: Type error: expected Object, got null
index e69de29..38398ad 100644 (file)
@@ -0,0 +1 @@
+alt/base_nullable_alt6.nit:44,18--19: Type error: expected Object, got nullable A
index e69de29..0668b65 100644 (file)
@@ -0,0 +1 @@
+alt/base_nullable_alt7.nit:46,18--19: Type error: expected Object, got nullable Object
diff --git a/tests/sav/base_nullable_alt9.sav b/tests/sav/base_nullable_alt9.sav
new file mode 100644 (file)
index 0000000..149f63f
--- /dev/null
@@ -0,0 +1 @@
+alt/base_nullable_alt9.nit:53,13--16: Type error: expected A, got null
index 128244e..ab79f16 100644 (file)
@@ -1 +1 @@
-alt/base_virtual_type2_alt1.nit:46,5--7: Type error: expected U, got T
+alt/base_virtual_type2_alt1.nit:46,5--7: Type error: expected nullable U, got nullable T
index 59b07a9..d99b18c 100644 (file)
@@ -1 +1 @@
-alt/base_virtual_type4_alt1.nit:24,8--12: Type error: expected U, got T
+alt/base_virtual_type4_alt1.nit:24,8--12: Type error: expected nullable U, got T
index 6d3aa69..e409041 100644 (file)
@@ -1 +1 @@
-alt/base_virtual_type5_alt1.nit:26,7--7: Type error: expected U, got Int
+alt/base_virtual_type5_alt1.nit:26,7--7: Type error: expected nullable U, got Int
index e6c4bee..56130b2 100644 (file)
@@ -1 +1 @@
-alt/base_virtual_type5_alt2.nit:27,7--11: Type error: expected U, got T
+alt/base_virtual_type5_alt2.nit:27,7--11: Type error: expected nullable U, got T
index e5f24e1..fe7f2e8 100644 (file)
@@ -1 +1 @@
-alt/base_virtual_type_alt1.nit:39,5--7: Type error: expected Int, got T
+alt/base_virtual_type_alt1.nit:39,5--7: Type error: expected Int, got nullable T
index 57c3b33..b86b1b0 100644 (file)
@@ -1 +1 @@
-alt/base_virtual_type_alt2.nit:40,7--7: Type error: expected T, got Int
+alt/base_virtual_type_alt2.nit:40,7--7: Type error: expected nullable T, got Int
index fd06cba..991e9ac 100644 (file)
@@ -1 +1 @@
-alt/base_virtual_type_alt3.nit:43,7--7: Type error: expected T, got B
+alt/base_virtual_type_alt3.nit:43,7--7: Type error: expected nullable T, got B
diff --git a/tests/sav/test_nil.sav b/tests/sav/test_nil.sav
deleted file mode 100644 (file)
index a616ad4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-01
\ No newline at end of file
index e86a5ff..5416e6a 100644 (file)
 # contributed by Jean Privat
 
 class TreeNode
-    attr _left: TreeNode
-    attr _right: TreeNode
+    attr _left: nullable TreeNode
+    attr _right: nullable TreeNode
     attr _item: Int
 
 
-    init(left: TreeNode, right: TreeNode, item: Int)
+    init(left: nullable TreeNode, right: nullable TreeNode, item: Int)
        do
            _left = left
            _right = right
@@ -65,7 +65,7 @@ if min_depth + 2 > max_depth then
 end
 
 var stretch_depth = max_depth + 1
-var stretch_tree = bottom_up_tree(0, stretch_depth)
+var stretch_tree: nullable TreeNode = bottom_up_tree(0, stretch_depth)
 
 print("stretch tree of depth {stretch_depth}\t check: {stretch_tree.item_check}")
 
index c1a0252..b8d555a 100644 (file)
 # limitations under the License.
 
 class A
-       attr _attribute: A
+       attr _attribute: nullable A
        attr _num: Char
 
-       meth foo=(a: A)
+       meth foo=(a: nullable A)
        do
                _attribute = a
        end
 
-       meth foo: A
+       meth foo: nullable A
        do
                return _attribute
        end
 
-       meth bar=(c: Char, a: A)   
+       meth bar=(c: Char, a: nullable A)   
        do
                _num = c
                _attribute = a
        end
 
-       meth bar(c: Char): A
+       meth bar(c: Char): nullable A
        do
                if c == _num then
                        return _attribute
@@ -61,7 +61,7 @@ class A
                _num = '*'
        end
 
-       init init2(c: Char, a: A)
+       init init2(c: Char, a: nullable A)
        do
                _num = c
                _attribute = a
index 585f652..1c5a1e0 100644 (file)
@@ -65,16 +65,16 @@ print(not 5 is b)
 print(not a is b)
 
 print("* null")
-a = null
-b = null
+var a1: nullable Object = null
+var b1: nullable Object = null
 print(not null is s)
 print(not s is null)
-print(not a is s)
-print(not s is a)
+print(not a1 is s)
+print(not s is a1)
 print(null is null)
-print(b is null)
-print(b is a)
+print(b1 is null)
+print(b1 is a1)
 print(not i is null)
-print(not i is a)
+print(not i is a1)
 print(not null is i)
-print(not a is i)
+print(not a1 is i)
index dd7edd7..74342a2 100644 (file)
@@ -19,8 +19,8 @@ class A
        init do end
 end
 
-var a = new A
-var b: A = null
+var a: nullable A = new A
+var b: nullable A = null
 if a == null then printn(0) else printn(1)
 if a is null then printn(0) else printn(1)
 #if b == null then printn(1) else printn(0)
index d658002..e03fbad 100644 (file)
@@ -23,28 +23,27 @@ special Object
    meth f: F do return _f_ end 
    meth f=(x: F) do _f_ = x end
 
-   init do end
+   init(e:E) do _e = e
 end
 
 class Gen2[G: Int]
 special Gen1[G, Char]
-
-   init do end
+   init(e:G) do super(e)
 end
 
 class Gen3[H: Int]
 special Gen1[H, Char]
    redef readable redef writable redef attr _e: H
-   redef attr _f_: Char
+   redef attr _f_: Char = 'N'
    redef meth f: Char do return _f_ end 
    redef meth f=(x: Char) do _f_ = x end
 
-   init do end
+   init(e:H) do super(e)
 end
 
-var g1 = new Gen1[Int, Char]
-var g2 = new Gen2[Int]
-var g3 = new Gen3[Int]
+var g1 = new Gen1[Int, Char](1)
+var g2 = new Gen2[Int](2)
+var g3 = new Gen3[Int](3)
 g1.e = 1
 g1.f = '1'
 g2.e = 2
index ab3ba79..f008c34 100644 (file)
@@ -34,10 +34,10 @@ print(not a2 isa Discrete)
 print(a2 isa Object)
 
 print("null:")
-var a3: Object = null
-print(a3 isa Int)
-print(a3 isa String)
-print(a3 isa AbstractArray[Char])
-print(a3 isa Iterator[Int])
-print(a3 isa Discrete)
-print(a3 isa Object)
+var a3: nullable Object = null
+print(a3 isa nullable Int)
+print(a3 isa nullable String)
+print(a3 isa nullable AbstractArray[Char])
+print(a3 isa nullable Iterator[Int])
+print(a3 isa nullable Discrete)
+print(a3 isa nullable Object)
diff --git a/tests/test_nil.nit b/tests/test_nil.nit
deleted file mode 100644 (file)
index dbac319..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-var a: Object = null
-var b: Object = null
-var c = a
-var d = "coucou"
-d = null
-printn(0)
-printn(null)
-printn(a)
-printn(b)
-printn(c)
-printn(d)
-printn(1)
index b6c509a..8b51728 100644 (file)
@@ -27,7 +27,7 @@ class A
        end
 end
 
-var a: A = null
+var a: nullable A = null
 if a != null then
        a.foo
        a.bar.output
index f7a25e1..2f6101d 100644 (file)
@@ -15,9 +15,9 @@
 # limitations under the License.
 
 class A
-    attr _foo: Object
-    attr _bar: A
-    attr _baz: Int
+    attr _foo: nullable Object
+    attr _bar: nullable A
+    attr _baz: nullable Int
     redef meth output do 'A'.output end
 
     init do end
@@ -25,8 +25,8 @@ end
 
 class B
 special A
-    redef attr _foo: Int
-    redef attr _bar: B
+    redef attr _foo: nullable Int
+    redef attr _bar: nullable B
     redef meth output do 'B'.output end
 
     init do end