[mcs] Fix parsing of interpolated strings inside conditional expression. Fixes #28293
authorMarek Safar <marek.safar@gmail.com>
Wed, 25 Mar 2015 15:32:19 +0000 (16:32 +0100)
committerMarek Safar <marek.safar@gmail.com>
Wed, 25 Mar 2015 15:34:29 +0000 (16:34 +0100)
mcs/mcs/cs-tokenizer.cs
mcs/tests/test-interpolation-05.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_5.xml

index 86902e3a6af708a84a0514589bedb76492eeeeab..38f992d652c756a84ae48418fa545fd9c92182d5 100644 (file)
@@ -409,6 +409,7 @@ namespace Mono.CSharp
                        public int parsing_generic_less_than;
                        public int current_token;
                        public object val;
+                       public int parsing_string_interpolation;
 
                        public Position (Tokenizer t)
                        {
@@ -427,6 +428,7 @@ namespace Mono.CSharp
                                        ifstack = new Stack<int> (clone);
                                }
                                parsing_generic_less_than = t.parsing_generic_less_than;
+                               parsing_string_interpolation = t.parsing_string_interpolation;
                                current_token = t.current_token;
                                val = t.val;
                        }
@@ -471,6 +473,7 @@ namespace Mono.CSharp
                        previous_col = p.previous_col;
                        ifstack = p.ifstack;
                        parsing_generic_less_than = p.parsing_generic_less_than;
+                       parsing_string_interpolation = p.parsing_string_interpolation;
                        current_token = p.current_token;
                        val = p.val;
                }
@@ -1296,6 +1299,7 @@ namespace Mono.CSharp
                        case Token.NULL:
                        case Token.THIS:
                        case Token.NEW:
+                       case Token.INTERPOLATED_STRING:
                                next_token = Token.INTERR;
                                break;
                                
diff --git a/mcs/tests/test-interpolation-05.cs b/mcs/tests/test-interpolation-05.cs
new file mode 100644 (file)
index 0000000..c604b51
--- /dev/null
@@ -0,0 +1,14 @@
+using System;
+
+public class ParserTest
+{
+       void Test1 ()
+       {
+               bool b = true;
+               Console.WriteLine(b ? $"{1:0.00}" : $"bar");
+       }
+
+       public static void Main()
+       {
+       }
+}
\ No newline at end of file
index 723567163936f8c337ee8e09afdef868c14a9eb1..5402f2276a60f4d2f399ef1a21fc09f6baa9f597 100644 (file)
       </method>
     </type>
   </test>
+  <test name="test-interpolation-05.cs">
+    <type name="ParserTest">
+      <method name="Void Test1()" attrs="129">
+        <size>41</size>
+      </method>
+      <method name="Void Main()" attrs="150">
+        <size>2</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-iter-01.cs">
     <type name="X">
       <method name="Int32 Main()" attrs="150">