-
Notifications
You must be signed in to change notification settings - Fork 802
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
Optimize interpolated string with no holes #11632
Conversation
If I were to create a reduction of |
An analyzer is the correct solution isn't it? |
Yes, it's pointless and no one sets out to write that initially, but I can imagine a scenario where there was actual interpolation, then someone removed it, but forgot the |
Yes, and the right solution is to help fix the code (using analyzers) rather than work around it. Isn't it? |
I'd say a compiler/analyzer warning would be complementary, and concerned with code style rather than performance. There's no reason we should emit suboptimal code if the user does not notice or heed the warning (when it's this easy to fix, to be precise). If you consider one extra character a crime against humanity, by all means go ahead and also implement an analyzer. I'm not fussed myself. |
I think this is a fine addition. We're not in the business of punishing people for writing what someone might personally find to be bad code. |
:) |
let flexes = argTys |> List.map (fun _ -> false) | ||
let fillExprs, tpenv = TcExprs cenv env m tpenv flexes argTys synFillExprs | ||
if List.isEmpty synFillExprs then | ||
let str = mkString g m printfFormatString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this changes the quotation form for an interpolated string. I don't mind that change, however could you add a test in tests/fsharp/core/quotes/test.fsx
or elsewhere to test for that and pin down the new form please?
e.g. check results of <@ $"abc" @>
and you may as well add a test for <@ $"abc {1} def" @>
while you're at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, just add a test for quotation forms please
Done. Will the test run automatically or do I need to wire it up somewhere? |
All of the initialization code of quotes/test.fsx runs automatically as one test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, subject to green ticks
becomes
instead of