]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Improve missing exponent check for real literals
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 30 Jan 2023 13:56:07 +0000 (14:56 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 30 Jan 2023 13:57:36 +0000 (14:57 +0100)
tests/basic-types/float-literals.c-expected
tests/basic-types/float-literals.vala
vala/valarealliteral.vala

index baa5423a14578a0c09b3bec107bd27028f1aeea5..2447e3e680f66840160c43da21f9a181d163a37e 100644 (file)
@@ -22,6 +22,12 @@ _vala_main (void)
                foo = 23.42;
                bar = 47.11;
        }
+       {
+               gdouble foo = 0.0;
+               gfloat bar = 0.0F;
+               foo = 23.42e+12;
+               bar = 47.11E-4f;
+       }
        {
                gdouble foo = 0.0;
                gdouble bar = 0.0;
index b4bba83a4ef5b7272e025e120f7f60fffe664acc..73119c9a76d7c6c2330d99fef15c9f13a0b63921 100644 (file)
@@ -7,6 +7,10 @@ void main () {
                double foo = 23.42D;
                double bar = 47.11d;
        }
+       {
+               double foo = 23.42e+12d;
+               float bar = 47.11E-4f;
+       }
        {
                double foo = 23.42;
                double bar = 47.11;
index c992fba6fd10433017bdaf3b8b75caa3c635180a..86e7cf5c11d22a7856359aac2a7b6b27f71d4d9e 100644 (file)
@@ -71,7 +71,7 @@ public class Vala.RealLiteral : Literal {
                        type_name = "double";
                }
 
-               if (value.has_suffix ("e") || value.has_suffix ("+") || value.has_suffix ("-")) {
+               if (value.has_suffix ("e") || value.has_suffix ("E") || value.has_suffix ("+") || value.has_suffix ("-")) {
                        Report.error (source_reference, "exponent has no digits");
                        error = true;
                }