Skip to content

Instantly share code, notes, and snippets.

@nicwise
Created July 26, 2013 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicwise/6090436 to your computer and use it in GitHub Desktop.
Save nicwise/6090436 to your computer and use it in GitHub Desktop.
Crashes the Mono 3.2.0 compiler
public class MainThing
{
public static void Main(string[] args)
{
var foo = new Foo();
foo.Die();
}
}
public class Foo
{
public string s = "";
public void Die()
{
// this line throws a valid compiler error
///Error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement (CS0201) (JuhaTweet)
//(s == "hello" ? MarkAsSent() : MarkAsDraft());
//this does too:
/*
Action zzz = () => {
int i = 4;
switch (i)
{
case 4:
(s == "hello" ? MarkAsSent () : MarkAsDraft ());
break;
}
};
zzz ();
*/
//this crashes the compiler
Task.Factory.StartNew (() => {
int i = 4;
switch (i)
{
case 4:
(s == "hello" ? MarkAsSent () : MarkAsDraft ());
break;
}
});
/*
* Building: JuhaTweet (Debug|x86)
Performing main compilation...
/Library/Frameworks/Mono.framework/Versions/3.2.0/bin/mcs /noconfig "/r:/Library/Frameworks/Mono.framework/Versions/3.2.0/lib/mono/4.5/mscorlib.dll"
-nostdlib "/out:/Users/nic/code/temp/JuhaTweet/JuhaTweet/bin/Debug/JuhaTweet.exe" "/r:/Library/Frameworks/Mono.framework/Versions/3.2.0/lib/mono/4.5/System.dll"
"/r:/Users/nic/code/temp/JuhaTweet/packages/LinqToTwitter.2.1.07/lib/net40/LinqToTwitter.dll"
"/r:/Library/Frameworks/Mono.framework/Versions/3.2.0/lib/mono/4.5/System.Core.dll"
"/r:/Library/Frameworks/Mono.framework/Versions/3.2.0/lib/mono/4.5/System.Core.dll"
/nologo /warn:4 /debug:full /optimize- /codepage:utf8 /platform:x86 "/define:DEBUG"
/t:exe "/Users/nic/code/temp/JuhaTweet/JuhaTweet/Program.cs" "/Users/nic/code/temp/JuhaTweet/JuhaTweet/Properties/AssemblyInfo.cs"
Compilation failed: 2 error(s), 0 warnings
Build complete -- 1 error, 0 warnings
*
*
*/
}
void MarkAsSent () {
}
void MarkAsDraft() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment