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 530698 - Cannot have local variables called error or self
Cannot have local variables called error or self
Status: RESOLVED DUPLICATE of bug 469335
Product: vala
Classification: Core
Component: Code Generator
0.3.x
Other All
: Normal normal
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-04-30 08:53 UTC by Jaap A. Haitsma
Modified: 2008-05-10 19:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
naive find & replace patch (31.49 KB, patch)
2008-05-05 07:16 UTC, Jared Moore
rejected Details | Review

Description Jaap A. Haitsma 2008-04-30 08:53:40 UTC
E.g the the code below code is accepted by the vala compiler but the C compiler complains because error and self are defined twice.

Probably best to solve this by prefixing "hidden" variables with two underscores. One underscore is sometimes used by people for fields

using GLib;

public class Sample : GLib.Object{

	public void foo () throws MyError {
		int error = 0;
		int self = 5;
		throw new MyError.FAILED ("Hello");
	}

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

public errordomain MyError {
	FAILED,
	SYNTAX	
}
Comment 1 Jared Moore 2008-05-05 07:16:57 UTC
Created attachment 110391 [details] [review]
naive find & replace patch

Done by find & replace. I didn't manually check that every single change is correct, but it all seems to work.
Comment 2 Jürg Billeter 2008-05-10 19:25:30 UTC
Thanks for the patch, however, I see two issues with the proposed patch. For one, there are more variables that can conflict, e.g. temporary variables and array length variables, and we should probably fix this together in a more general way.

The other issue is that I only want to change the generated variable name where necessary instead of always using harder to read variable names everywhere, especially for parameter names like `self' that might be visible in public header files. It might even make sense to rename the local `self' variables instead of the generated `self' parameter.
Comment 3 Jürg Billeter 2008-05-10 19:25:49 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.


*** This bug has been marked as a duplicate of 469335 ***