Commit 2f6d9c44 authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Discover invalid member access to instance field

https://bugzilla.gnome.org/show_bug.cgi?id=790903
parent 03e7508d
......@@ -571,6 +571,14 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
inst = pub_inst;
}
if (inst == null) {
// FIXME Report this with proper source-reference on the vala side!
Report.error (field.source_reference, "Invalid access to instance member `%s'".printf (field.get_full_name ()));
result.cvalue = new CCodeInvalidExpression ();
return result;
}
if (instance_target_type.data_type.is_reference_type () || (instance != null && instance.value_type is PointerType)) {
result.cvalue = new CCodeMemberAccess.pointer (inst, get_ccode_name (field));
} else {
......
......@@ -117,6 +117,7 @@ TESTS = \
control-flow/bug691514.vala \
control-flow/bug736774-1.vala \
control-flow/bug736774-2.vala \
control-flow/bug790903.test \
enums/enum_only.vala \
enums/enums.vala \
enums/flags.vala \
......
Invalid Code
class Foo {
public string field;
}
void main () {
var foo = (string) Foo.field;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment