-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection of findings related to string interpolation #9893
Comments
@abelbraaksma Thanks so much for trying this out! I'll get these fixed right now |
Thanks, this bug hits when the specifiers are next to each other (which wasn't covered in our test suite). I've fixed it now in the feature branch |
I agree this should be invalid, thanks |
The first two problems are fixed in feature/string-interp
@cartermp would like this too, I think it's reasonable. |
Interesting, Rider and ReSharper highlight the "holes" in interpolated strings and string.Format calls differently:
So that's some interesting prior art |
Glad it was helpful and could be fixed easily 👍. But this got auto-closed due to the merge, with parts of the issue still open/unaddressed. Shall I post the rest again separately, or can you (@KevinRansom, @dsyme) reopen this? (I don't have enough rights to do that). I assume subsequent fixes will go to master and the feature branch gets removed? |
@abelbraaksma , issues will be addressed as bugs in the normal way. |
@abelbraaksma can you go through and add a checklist item for each thing you noticed, marking the ones that are addressed? |
@cartermp, done, I gave each bug a sensible (sub)title and on top there's a simple checklist of each of them. |
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f396177996a7d63e1ce650423993f07facd8239. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet/fsharp#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (#9516) (#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) (#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) (#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (#9644) (#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (#9657) (#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (#9657) (#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (#9839) (#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet/fsharp#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
@dsyme, I've added a bunch of issues in the last hour or so. Nothing egregious, I think. |
I tried @abelbraaksma's directions and got FS3353 saying I need language version preview, even though I have
|
Nice work @abelbraaksma .
This should be an error. Representing an empty string, or "nothing", or null, or None, as a empty space is not allowed in other places in F# (e.g. |
EDIT: there was an error in my original instruction, I wrote But the error you saw, @zanaptak, is about the reference to the @charlesroddie, you've got a good point. There's actually a PR right now that's addressing that very thing to get a more meaningful error. |
@zanaptak, for reference, I'll copy the instructions here as well (and created an issue to smoothen the situation in the future: #9904): For anybody wanting to play around with the latest build of this feature (esp. those that aren't aware how to do this and are curious where to start):
A new VS instance is started with the new features selected, but when you create a project, it will, by default, reference an FSharp.Core.dll from NuGet. To fix this:
A minimal project file for <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<LangVersion>preview</LangVersion>
<!-- either the prev. line, or the following line -->
<OtherFlags>--langversion:preview</OtherFlags>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningsAsErrors>3239;25</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>D:\Projects\OpenSource\FSharp\artifacts\bin\VisualFSharpFull\Release\net472\FSharp.Core.dll</HintPath>
</Reference>
</ItemGroup>
</Project> Now you can start typing your code without errors along the line of "Feature 'string interpolation' requires the F# library for language version 4.7 or greater." (an error you will also get if your project actually references 4.7.0, but that's a bug for another time, or maybe I just screwed something up locally). |
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f39617. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (dotnet#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (dotnet#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (dotnet#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (dotnet#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (dotnet#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (dotnet#9516) (dotnet#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (dotnet#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (dotnet#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (dotnet#9644) (dotnet#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (dotnet#9657) (dotnet#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (dotnet#9657) (dotnet#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) (dotnet#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
I already had the disabling and the file reference in place, I'll try the new flag later. Should we use master branch now since it's merged and may get ongoing fixes? |
Yes, you can use the master branch. Feel free to ping me on slack if you have trouble, I'm also trying to get a clear picture of the issues with running from a fresh build. Btw, you do need to run build from a vs 2019 developer command prompt, I think. |
I don't get this. This is an interpolated single quote string containing a single quote string applied to Single quote strings containing a single quote string are not allowed but that is separate. Adding some spacing may help see what's going on:
|
Thank you so much for your amazing QA work here!! |
(I'll be reading the rest more closely on Monday) |
@dsyme I meant to say (see screenshot) that I expect the error to end at the invalid last opening
The rest of that line is whitespace and comment (but becomes part of the error). It appears as if there's a greedy regex match going on, instead of a non greedy one. This may also be because currently, the parser tries to find out whether the user attempts to nest another interpolated string inside it, and is conflicts with the user being half way inside typing a valid expression (he just opened the next curly), coloring the rest of the file as error. |
I'm first trying to work out if there are must-fix issues here I think these are by-design:
These are all potential future improvements?
|
I would consider some of them bugs, and not just improvements (esp the multiline issues), but fixing a bug is an improvement, isn't it? ;). Though none of them are likely showstoppers, before this gets wildly used, it may be good if we can iron out some of these.
@dsyme The problem with these is that Surprising stuff happens when you are just typing, which creates a scary experience while you are in de middle of an interpolated string. In heavy files, the constant "whole file is an error" experience may lead to heavy spinning of VS. |
@abelbraaksma, reporting this from the slack channel: There seems to be the following issue with embedding string literals inside interpolated strings. I was able to produce the following error in FSI:
This is my fsi version info:
My dotnet info:
my FSharp.Core version is |
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f39617. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (dotnet#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (dotnet#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (dotnet#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (dotnet#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (dotnet#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (dotnet#9516) (dotnet#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (dotnet#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (dotnet#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (dotnet#9644) (dotnet#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (dotnet#9657) (dotnet#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (dotnet#9657) (dotnet#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) (dotnet#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
I'm going to close out this old issue - many thanks to @abelbraaksma for the very detailed work which was crucial in shipping this feature |
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f39617. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (dotnet#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (dotnet#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (dotnet#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (dotnet#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (dotnet#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (dotnet#9516) (dotnet#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (dotnet#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (dotnet#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (dotnet#9644) (dotnet#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (dotnet#9657) (dotnet#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (dotnet#9657) (dotnet#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) (dotnet#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f39617. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (dotnet#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (dotnet#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (dotnet#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (dotnet#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (dotnet#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (dotnet#9516) (dotnet#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (dotnet#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (dotnet#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (dotnet#9644) (dotnet#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (dotnet#9657) (dotnet#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (dotnet#9657) (dotnet#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) (dotnet#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
@dsyme, I know you closed this, but some of the unaddressed issues are still quite apparent. For instance: And this should just be an error like "String with unclosed opening curly bracket", but instead: I mean, while they only "wreck" the editor temporarily, I think they are still bug and people see these things while they're typing the opening curly inside a string. An error like this would make more sense: But yeah, I get that these are all pretty fringe in the end. |
EDIT: if you want to test this awesome feature yourself (or any other "latest" feature), I've written up (and today, 9 Aug, corrected) a little instruction here: #9893 (comment)
Just some findings I collect here about the upcoming string interpolation feature. Some may be "by design", or may already have been reported, but I offered @cartermp to do some testing, so here it goes ;).
For: #8907 (I used the latest successful build of the PR, of earlier today). Details of feature in RFC: https://github.com/fsharp/fslang-design/blob/master/preview/FS-1001-StringInterpolation.md.
Some additional notes (but not bugs afaict) in this comment by @cartermp: #8907 (comment)
Summary and todo-list
Printf.StringFormat
, errors can be all over the placeSummary of things tested so far (8/8/2020)
#if
statement in multiline expressions just work as expected# lineno
statements just work as expected inside interp expr#compdirective
, when invalid, wreaks havoc, much more than it used to (see "weird behavior" issue above)StringFormat
tested, some findings, see above$"%i{x}
requiresx
to be integer)%
-style and interp-style disallowed, this is as expectedkprintf
worksStringFormat
does not work with interp strings, I guess this is as expected:module
andtype
give the proper errors.Half of the expressions are not evaluatedfixed/testedIt turns out that there's an issue with the third and subsequent string interpolation section in a composed string, leading to weird results (note how the "." get misplaced). It appears thatonly
noOfExpr idiv 2 + 1
get evaluated:Non-escaped closing curly considered legalfixed/testedThe following came as a surprise to me, but may be based on how C# does things? This came as a surprise, I'd expect orthogonality here:
Empty expr between curlies
I'd prefer this to be legal, esp in light of autogen tools, that now have to put in
null
orNone
to eval to nothing, or remove the expr part:Prefix operators don't work on interp strings
It's (quite) customary to (re)define unary prefix operators and they used to work "just fine" with strings, but they don't work the same way with interpolated strings, because
$
is considered part of the prefix operator. Since it is already forbidden to have an operator contain the dollar sign (except for dollar-only operators), I think this should be legal:Colors of curlies in tooling
Maybe we can distinguish colors of active
{
vs escaped{
? It's pretty hard to notice the difference. Maybe we can make the active ones bright-red or something?Expression past closing quote considered part of the expression, making comments part of the interp string
This gives "this value is not a function an cannot be applied" error, and wrongly colors the rest of the line:
This same behavior leads to other weird stuff, where the syntax checker keeps looking beyond the last quote:
Or this one, each line getting red to the end of file:
Wrong error range for missing closing curly, or extra open curly-at-end
Like this:
With combinator for
Printf.StringFormat
, errors can be all over the place(it's actually awesome that this works mostly flawlessly and that I can re-use existing stringformat combinators!)
The following code gets errors all over the place in the whole file:
See the 4 (!) errors in this animation, it should ideally be only one on wrong interp string:
Use with literal gives too many errors
I can understand that use with literals is not allowed, not even when it can be assessed that the result of an interp string will be constant. But there are two errors raised, instead of one:
Really weird behavior when (wrongly) using compiler directives + multiline expr in interp strings
I've no idea what happens here, there seems to be nothing consistent. Everything gets green and improper errors pop up. The red
#
is as it is now (unexpected symbol in binding), the rest getting green not at all. Notice that this behavior disappears when the interpolated expression part is a single constant.Repo code:
Multiline woes, wrong error-underline calculation
Multiline woes, coloring is off, part of string default color
Multiline woes: mysterious errors that are not an error when compiled
This situation appears to depend on the size of the input (and is not necessarily related to the new feature, I can confirm this was the case previously):
Error is depending on text length in last line, it seems:
Potential error improvements
Here are some areas where we may want to improve error reporting.
Something about hinting like "remove whitespace between '{' and % expression" perhaps?
Text doesn't match the error, should be something like "Unclosed opening bracket in interpolated string found at position X in string":
Not sure how this can be improved, but the user here escaped the curly, but then gets an error that (s)he needs to escape the curly? Maybe we can report all situations where
openingCurlies - closingCurlies <> 0
(excluding escapes) as a variant of "missing opening or closing bracket"? This would solve a range of error issues, I think.This is cool!
I just have to say I really like it that the result inside
{...}
is not just a string, but keeps type information, and that the result can be formatted. So this is entirely expected (and%f
fixes the error):I'll update this list if I find more stuff (it's getting a bit late over here ;) ).
Anybody else who'd like to try out this new feature and iron out some bugs, here's how to use the absolute latest, I've written some instructions in the PR: #9893 (comment)
The text was updated successfully, but these errors were encountered: