[vala/0.40] genie: Fix parser's inner state when a struct is declared after a class



commit d2e9abbe3569351bda412bb2fd6dd5ab62f93f11
Author: Jeremy Philippe <jeremy philippe gmail com>
Date:   Sat Dec 21 20:55:53 2019 +0100

    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.

 vala/valagenieparser.vala | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 1cfd0366f..7e87a11ee 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -3300,6 +3300,8 @@ public class Vala.Genie.Parser : CodeVisitor {
 
                expect (TokenType.EOL);
 
+               class_name = st.name;
+
                parse_declarations (st);
 
                Symbol result = st;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]