[mcs] Report interpolated strings feature. Fixes #42410
authorMarek Safar <marek.safar@gmail.com>
Tue, 26 Jul 2016 15:44:28 +0000 (17:44 +0200)
committerMarek Safar <marek.safar@gmail.com>
Tue, 26 Jul 2016 15:47:09 +0000 (17:47 +0200)
mcs/errors/cs1644-50.cs [new file with mode: 0644]
mcs/mcs/cs-parser.jay

diff --git a/mcs/errors/cs1644-50.cs b/mcs/errors/cs1644-50.cs
new file mode 100644 (file)
index 0000000..10817d7
--- /dev/null
@@ -0,0 +1,11 @@
+// CS1644: Feature `interpolated strings' cannot be used because it is not part of the C# 5.0 language specification
+// Line: 9
+// Compiler options: -langversion:5
+
+public class Program
+{
+       public static void Main()
+       {
+               var x = $"I should not compile";
+       }
+}
index 6783a7edbb672ef70e00d3684e3f35427ea12eab..bb2bd6e19718cad38c3cf37e8eb131b1b6581685 100644 (file)
@@ -3351,10 +3351,16 @@ boolean_literal
 interpolated_string
        : INTERPOLATED_STRING interpolations INTERPOLATED_STRING_END
          {
+               if (lang_version < LanguageVersion.V_6)
+                       FeatureIsNotAvailable (GetLocation ($1), "interpolated strings");
+
                $$ = new InterpolatedString ((StringLiteral) $1, (List<Expression>) $2, (StringLiteral) $3);
          }
        | INTERPOLATED_STRING_END
          {
+               if (lang_version < LanguageVersion.V_6)
+                       FeatureIsNotAvailable (GetLocation ($1), "interpolated strings");
+
                $$ = new InterpolatedString ((StringLiteral) $1, null, null);
          }
        ;