]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Don't require constant initializer in fast-vapi
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Nov 2019 20:04:42 +0000 (21:04 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 18 Nov 2019 08:34:10 +0000 (09:34 +0100)
Regression of 984c034256de3830d6daa0ab6f5eff108dea09bb

Extend --fast-vapi test by using --use-fast-vapi

See https://github.com/dino/dino/issues/646
and https://gitlab.gnome.org/GNOME/vala/issues/461

codegen/valaccodebasemodule.vala
vala/valaconstant.vala

index f23c42b421607b1a3224f65e8a7a6be523851410..cb5ee3750a6c334dfebf594fdddd58aed62f6ab6 100644 (file)
@@ -961,7 +961,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        return;
                }
 
-               if (!c.external) {
+               if (!c.external || (c.source_type == SourceFileType.FAST && c.value != null)) {
                        generate_type_declaration (c.type_reference, decl_space);
 
                        c.value.emit (this);
index 0a9266cf178f701560096bb003f6abc93b2fa0d3..b98568f3321cf5364c646eca9f890a8a0f656a30 100644 (file)
@@ -123,8 +123,11 @@ public class Vala.Constant : Symbol {
 
                if (!external) {
                        if (value == null) {
-                               error = true;
-                               Report.error (source_reference, "A const field requires a value to be provided");
+                               // constants from fast-vapi files are special
+                               if (source_type != SourceFileType.FAST) {
+                                       error = true;
+                                       Report.error (source_reference, "A const field requires a value to be provided");
+                               }
                        } else {
                                value.target_type = type_reference;