summaryrefslogtreecommitdiff
path: root/tests/genie
diff options
context:
space:
mode:
authorJeremy Philippe <jeremy.philippe@gmail.com>2019-12-21 20:55:53 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2020-01-06 09:29:36 +0100
commit1384dd0bac5a93721e1ca11efed51fba4cb050ed (patch)
treed5f622e449f56958a617d007e79286d82efb3b78 /tests/genie
parent4e78d7713e80ce0b3044979e848b78229a1b6061 (diff)
downloadvala-1384dd0bac5a93721e1ca11efed51fba4cb050ed.tar.gz
genie: Fix parser's inner state when a struct is declared after a class
If the struct is declared after a class and has a default creation method, the parser will raise a "missing return type in method ..." error. The cause of the bug is that the global 'class_name' variable is not updated when the parser encounters a struct, so the previous value is used, and if a class has been parsed before, this value will be the name of the class instead of the struct.
Diffstat (limited to 'tests/genie')
-rw-r--r--tests/genie/struct-after-class.gs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/genie/struct-after-class.gs b/tests/genie/struct-after-class.gs
new file mode 100644
index 000000000..353012bc3
--- /dev/null
+++ b/tests/genie/struct-after-class.gs
@@ -0,0 +1,13 @@
+init
+ var a = new TestClass()
+ var b = TestStruct()
+ assert( a.empty == b.empty )
+
+class TestClass
+ empty:string = ""
+
+struct TestStruct
+ empty:string
+
+ construct()
+ empty = ""