GNOME Bugzilla – Bug 664049
Misleading compile warning when passing constant value to 'out' parameter
Last modified: 2016-10-13 14:27:43 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
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
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