From 8ffeebe53771d774870086fe36045c550cc9dde7 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sat, 9 Feb 2013 15:30:23 -0500 Subject: [PATCH] C# Evaluator, Terse syntax fix. The terse syntax added a semicolon automatically, but that also meant that things lik: csharp> for (int i = 0; i < 10; i++) Would never get a continuation for partial input, since the semicolon woudl make that a valid block. Fix that by first trying to add a block at the end, if that works, then we know we want to continue, otherwise we insert the semicolon. --- mcs/mcs/eval.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mcs/mcs/eval.cs b/mcs/mcs/eval.cs index 6810507d063..457bff4986b 100644 --- a/mcs/mcs/eval.cs +++ b/mcs/mcs/eval.cs @@ -226,9 +226,16 @@ namespace Mono.CSharp bool partial_input; CSharpParser parser = ParseString (ParseMode.Silent, input, out partial_input); + + // Terse mode, try to provide the trailing semicolon automatically. if (parser == null && Terse && partial_input){ bool ignore; - parser = ParseString (ParseMode.Silent, input + ";", out ignore); + + // check if the source would compile with a block, if so, we should not + // add the semicolon. + var needs_block = ParseString (ParseMode.Silent, input + "{}", out ignore) != null; + if (!needs_block) + parser = ParseString (ParseMode.Silent, input + ";", out ignore); } if (parser == null){ compiled = null; -- 2.25.1