Bug 4164 - mcs should warn about obvious property getter/setter stack overflows
Summary: mcs should warn about obvious property getter/setter stack overflows
Status: NEW
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2012-03-30 17:34 UTC by Mikayla Hutchinson [MSFT]
Modified: 2012-03-30 17:34 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Mikayla Hutchinson [MSFT] 2012-03-30 17:34:44 UTC
It's very easy to typo a field name in property getters and setters, e.g.

int foo = 0;
public int Foo {
    set { foo = value; }
    get { return Foo; }
}

In the case of trivial getters (return itself) and setters (assign itself), it's obvious that all this can do is cause a stack overflow. The compiler should warn (or error!) on this, so it can be caught at compile time instead of runtime.

This would be particularly helpful on Mac, where stack overflows in Mono app are extremely hard to debug.

Note You need to log in before you can comment on or make changes to this bug.