Base-access inside of non-gtype type-symbols generates invalid c-code
-
1 SimpleType inheritance with this
[IntegerType (rank = 6, signed = true, width = 32)]
[SimpleType]
[CCode (has_type_id = false)]
struct foo_t {
public int x10(){
return this * 10;
}
}
struct bar: foo_t {
public int x20(){
return this * 20;
}
}
void main () {
}
C Error
/ TMP / B. the shaft.AOSME0.c: 35: 1: error: unknown type name "gtype»
35 / GType
| ^~~~~
/ TMP / B. the shaft.AOSME0.c: In the "bar_get_type" function»:
/ TMP / B. the shaft.AOSME0.c: 40: 3: error: unknown type name "gtype»
40 / GType bar_type_id;
| ^~~~~
/ TMP / B. the shaft.AOSME0.c: 41: 17: warning: implicit Declaration of the function "g_boxed_type_register_static" [- wimplicit-function-Declaration]
41 / bar_type_id = g_boxed_type_register_static ("bar", (GBoxedCopyFunc) bar_dup, (GBoxedFreeFunc) bar_free);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/ TMP / B. the shaft.AOSME0.c: 41: 55: error: "gboxedcopyfunc" not described (First use in this function)" did you mean "gcopyfunc"?
41 / bar_type_id = g_boxed_type_register_static ("bar", (GBoxedCopyFunc) bar_dup, (GBoxedFreeFunc) bar_free);
| ^~~~~~~~~~~~~~
| GCopyFunc
/ TMP / B. the shaft.AOSME0.c: 41: 55: note: a message about each undescribed identifier is issued once in each function where it occurs
/ TMP / B. the shaft.AOSME0.c: 41: 70: error: expected") "before" bar_dup»
41 / bar_type_id = g_boxed_type_register_static ("bar", (GBoxedCopyFunc) bar_dup, (GBoxedFreeFunc) bar_free);
| ^~~~~~~~
| )
error: cc exited with status 256
-
2 SimpleType Inheritance with base
The same code but withbase
instead ofthis
in thex20
method causes a different error:
C Error
/tmp/V. vala.PHYME0.c: In the "bar_x20" function»:
/tmp/V. vala.PHYME0.c:31:19: warning: implicit Declaration of the function "G_TYPE_CHECK_INSTANCE_CAST" [- Wimplicit-function-declaration]
31 | result = (gint) (G_TYPE_CHECK_INSTANCE_CAST (self,, foo_t) * 20);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/V. vala.PHYME0.c:31:53: error: expected expression before ", " token
31 | result = (gint) (G_TYPE_CHECK_INSTANCE_CAST (self,, foo_t) * 20);
| ^
/tmp/V. vala.PHYME0.c: at the top level:
/tmp/V. vala.PHYME0.c:35:1: error: unknown type name "GType»
35 / GType
| ^~~~~
/tmp/V. vala.PHYME0.c: In the "bar_get_type" function»:
/tmp/V. vala.PHYME0.c:40:3: error: unknown type name "GType»
40 / GType bar_type_id;
| ^~~~~
/tmp/V. vala.PHYME0.c:41:17: warning: implicit function Declaration "g_boxed_type_register_static" [- Wimplicit-function-declaration]
41 | bar_type_id = g_boxed_type_register_static ("bar", (GBoxedCopyFunc) bar_dup, (GBoxedFreeFunc) bar_free);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/V. vala.PHYME0.c:41:55: error: "GBoxedCopyFunc" is not described (first use in this function); was "GCopyFunc"meant?
41 | bar_type_id = g_boxed_type_register_static ("bar", (GBoxedCopyFunc) bar_dup, (GBoxedFreeFunc) bar_free);
| ^~~~~~~~~~~~~~
| GCopyFunc
-
3 Structs Inheritance with base
struct Foo {
int a;
int b;
public int sum(){
return a + b;
}
}
struct Bar : Foo {
public int square(){
return base.a * base.b;
}
}
void main () {
Foo foo = {5,6};
prin(foo.sum());
Bar bar = Bar();
prin(bar.sum());
prin(bar.square());
}
C Error
/tmp/V. vala.XF8LE0.c: In the "bar_square" function»:
/tmp/V. vala.XF8LE0.c:86:59: error: "(Foo *)g_type_check_instance_cast ((GTypeInstance *) self, foo_get_type ()) "pointer; meant to use" ->"?
86 | result = G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_FOO, Foo).a * G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_FOO, Foo).b;
| ^
| ->
/tmp/V. vala.XF8LE0.c:86:112: error: "(Foo *)g_type_check_instance_cast ((GTypeInstance *) self, foo_get_type ()) "pointer; meant to use" ->"?
86 | result = G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_FOO, Foo).a * G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_FOO, Foo).b;
| ^
| ->
error: cc exited with status 256
PS Errors have been translated into English, so they may be inaccurate in words.