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 664049 - Misleading compile warning when passing constant value to 'out' parameter
Misleading compile warning when passing constant value to 'out' parameter
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Semantic Analyzer
unspecified
Other Linux
: Normal minor
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-11-14 15:50 UTC by Sam Thursfield
Modified: 2016-10-13 14:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch: warn about mismatched parameter direction before mismatched type (2.20 KB, patch)
2011-11-30 16:26 UTC, Sam Thursfield
committed Details | Review

Description Sam Thursfield 2011-11-14 15:50:45 UTC
Testcase:

public void foo (out uint a)
{
	print ("%u\n", a);
}

int main (string args[])
{
	foo (0);
	return 0;
}


This will give the following compile warning:
out-params.vala:8.7-8.7: error: Argument 1: Cannot convert from `uint' to `int'

The problem is actually that I'm passing a constant integer to an 'out' param, so the warning is misleading
Comment 1 Sam Thursfield 2011-11-30 16:26:55 UTC
Created attachment 202456 [details] [review]
Patch: warn about mismatched parameter direction before mismatched type

Simple fix. I've realised this bug is perhaps a matter of taste, but I think the more severe error should be the one that is reported. In the above test-case (assuming foo() was in some library and not visible), I might see the type mismatch error and simply cast the value and try again. Giving 'Argument 1: Cannot pass value to reference or output parameter' more clearly explains the problem
Comment 2 Rico Tzschichholz 2016-10-13 14:27:38 UTC
commit 4bed25c2fe2a081537cb17f62a965ffa55937115
Author: Sam Thursfield <ssssam@gmail.com>
Date:   Wed Nov 30 17:26:00 2011 +0100

    Warn about mismatched parameter direction before mismatched type