After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 776827 - %s appearing inappropriately in error messages
%s appearing inappropriately in error messages
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Errors
0.35.x
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2017-01-03 18:10 UTC by Al Thomas
Modified: 2017-01-05 12:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
vala: Fix output of syntax errors reports (18.21 KB, patch)
2017-01-05 08:53 UTC, Rico Tzschichholz
committed Details | Review

Description Al Thomas 2017-01-03 18:10:15 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 ());
Comment 1 Rico Tzschichholz 2017-01-05 07:33:15 UTC
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
Comment 2 Rico Tzschichholz 2017-01-05 08:53:34 UTC
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.
Comment 3 Rico Tzschichholz 2017-01-05 12:35:26 UTC
Attachment 342929 [details] pushed as 77f31ad - vala: Fix output of syntax errors reports