Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Question about changed behavior of string interpolations in NativeAOT in the .NET 11 rc1 SDK

オープン
#20,757 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
1週間以上
初心者へのやさしさ
18/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
fsharp
領域
compilers

調査の方向性

The regression is in how the F# compiler lowers interpolated strings with format specifiers, so start from the interpolated-string lowering code and compare the .NET 10 and .NET 11 rc1 output for %02d in the fsharp repo. Reproduce with the NativeAOT snippet from the issue, then check the IL or decompiled output for the PrintFormatToString call shape. Done means the interpolated string runs under NativeAOT again, or a maintainer decides the change is intended and documents it. This is a compiler regression with no clear fix direction, so it is not a good first issue.

索引モデルが issue の本文から書いたものです。

説明

Bug Needs-Triage

Hi,

Not sure if this is a bug, or an expected change after https://github.com/dotnet/fsharp/pull/19971, but as it came across as a breaking change to me I'll ask in case.

When doing testing with https://github.com/fable-hub/Scriptorium/pull/21 I noticed that if I have the code

let now = System.DateTime.UtcNow

let startAt =
    $"%02d{now.Hour}:%02d{now.Minute}:%02d{now.Second}"

and compile that with NativeAOT using the .NET 10 SDK then the resulting executable works correctly, but compiling the same code with the .NET11-RC1 SDK then it crashes at runtime with an exception similar to the one in https://github.com/fable-hub/Scriptorium/pull/21.

This doesn't seem ideal, even given the known issues with F# style format specifiers, if it worked before and doesn't now?

fwiw, looking at the binary with ILSpy, the .NET 10 build that works decompiles as

string startAt2 = (startAt2@10 = ExtraTopLevelOperators.PrintFormatToString(new PrintfFormat<string, Unit, string, string, Tuple<int, int, int>>("%02d%P():%02d%P():%02d%P()", new object[3]
{
    Program.now.Hour,
    Program.now.Minute,
    Program.now.Second
}, null)));

and the .NET 11 build that doesn't shows as

string startAt2 = (startAt2@9 = ExtraTopLevelOperators.PrintFormatToString(new PrintfFormat<FSharpFunc<int, string>, Unit, string, string, int>("%02d")).Invoke(Program.now.Hour) + ":" + ExtraTopLevelOperators.PrintFormatToString(new PrintfFormat<FSharpFunc<int, string>, Unit, string, string, int>("%02d")).Invoke(Program.now.Minute) + ":" + ExtraTopLevelOperators.PrintFormatToString(new PrintfFormat<FSharpFunc<int, string>, Unit, string, string, int>("%02d")).Invoke(Program.now.Second));

Known workarounds

Doing $"{now.Hour:D2}:{now.Minute:D2}:{now.Second:D2}" works in the RC1 SDK, so it can at least be made to work that way.

Thanks.

主要言語
F#
スター
4.3k
フォーク
880
平均マージ
4日 14分
マージ済み PR(30日)
99

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/fsharp のほかの issue

dotnet/fsharp の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。