]> Nishi Git Mirror - gwion.git/commitdiff
:art: update ctor and super tests
authorfennecdjay <fennecdjay@gmail.com>
Thu, 8 Dec 2022 13:30:41 +0000 (14:30 +0100)
committerfennecdjay <fennecdjay@gmail.com>
Thu, 8 Dec 2022 13:30:41 +0000 (14:30 +0100)
src/parse/check.c
tests/ctor/ctor_return.gw
tests/ctor/parent_ctor_only_in_new.gw [deleted file]
tests/super/super.gw [new file with mode: 0644]
tests/super/super_not_call.gw [new file with mode: 0644]
tests/super/super_outside.gw [new file with mode: 0644]

index 9c0438050f2fe4d43c72b043546d80719fb5b0d9..fe3563977330eb5a5da51646eeee7874459116b9 100644 (file)
@@ -974,15 +974,6 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) {
       if(t) return t;
     }
   }
-//puts(t->name);
-//  if(!is_func(env->gwion, t)) {
-//    if(is_class(env->gwion, t)) {
-//      const Value v = nspc_lookup_value0(t->info->base_type->nspc, insert_symbol("new"));
-//      if(v) t = v->type;
-//    }
-// else
-//  }
-//exit(3);
   if(is_func(env->gwion, exp->func->type))
     function_alternative(env, exp->func->type, exp->args, exp->func->pos);
   return NULL;
index dc95d37147cccb8225f04d7357a839fe17d5f195..0e1659ffd39a6bfe5b88eecb06651d5a4f576f6e 100644 (file)
@@ -1,3 +1,4 @@
+#! [contains] statement inside constructor function should have no expression
 class C {
   operator new() { return this; }
 }
diff --git a/tests/ctor/parent_ctor_only_in_new.gw b/tests/ctor/parent_ctor_only_in_new.gw
deleted file mode 100644 (file)
index 5b0d2d2..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-class C {
-  operator new() {}
-}
-
-class D extends C{
-}
-
-var D d;
-d.C();
diff --git a/tests/super/super.gw b/tests/super/super.gw
new file mode 100644 (file)
index 0000000..812fb6d
--- /dev/null
@@ -0,0 +1,12 @@
+#! [contains] new@0@C
+class C {
+  operator new() { <<< __func__ >>>; }
+}
+class D extends C {
+}
+
+class E extends D {
+  operator new() { super();}
+}
+
+new D();
diff --git a/tests/super/super_not_call.gw b/tests/super/super_not_call.gw
new file mode 100644 (file)
index 0000000..9d1c6b0
--- /dev/null
@@ -0,0 +1,12 @@
+#! [contains] as a function call
+class C {
+  operator new() { <<< __func__ >>>; }
+}
+class D extends C {
+}
+
+class E extends D {
+  operator new() { super; }
+}
+
+new D();
diff --git a/tests/super/super_outside.gw b/tests/super/super_outside.gw
new file mode 100644 (file)
index 0000000..c39e57f
--- /dev/null
@@ -0,0 +1,12 @@
+#! [contains] outside of constructor
+class C {
+  operator new() { <<< __func__ >>>; }
+}
+class D extends C {
+}
+
+class E extends D {
+  super;
+}
+
+new D();