GNOME Bugzilla – Bug 776827
%s appearing inappropriately in error messages
Last modified: 2017-01-05 12:35:30 UTC
A simple Vala program that misses a semi-colon: void main () { string a = "" } This would have previously produced the error: test.vala:3.1-3.1: error: syntax error, expected `;' Instead latest Vala advises: test.vala:3.1-3.1: error: syntax error, expected %s Clearly "expected %s" is inappropriate and unhelpful. A couple more examples: 1. The following: void main () { if (true {} } with latest Vala gives: test.vala:2.11-2.11: error: syntax error, expected %s while previous versions reported: test.vala:2.11-2.11: error: syntax error, expected `)' 2. The following Genie code: init pass class pass with latest Vala reports: test.gs:4.2-4.5: error: syntax error, expected declaration but got %s with previous %s while previous versions reported: test.gs:4.2-4.5: error: syntax error, expected declaration but got `pass' with previous `tab indent' --- For the Genie example this error message is generated by the parse_declaration () method in the parser with the line: throw new ParseError.SYNTAX (get_error ("expected declaration but got %s with previous %s"), cur.to_string (), pre.to_string()); This includes the double space between "declaration" and "but". For the Vala examples it is probably the expect () method of the Vala parser and the line: throw new ParseError.SYNTAX (get_error ("expected %s"), type.to_string ());
300f81c2517d875b5e1331d893d42f3901e4563e is the first bad commit commit 300f81c2517d875b5e1331d893d42f3901e4563e Author: Jürg Billeter <j@bitron.ch> Date: Tue Nov 1 18:14:09 2016 +0100 Do not use non-literal printf format strings
Created attachment 342929 [details] [review] vala: Fix output of syntax errors reports get_error() did not take printf-formatted strings, it expected fully populated ones for direct usage with Report.error(). Output error message with report_parse_error() from try-catch-statements.
Attachment 342929 [details] pushed as 77f31ad - vala: Fix output of syntax errors reports