fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Support `CallerArgumentExpression`

Open ijklam opened this issue 1 year ago • 10 comments

Description

Implements fsharp/fslang-suggestions#966, #18489

RFC FS-1149-support-CallerArgumentExpression.md, FS-1332-assert-keyword-enhancement.md

图片

Checklist

  • [x] Test cases added
  • [ ] Performance benchmarks added in case of performance changes
  • [x] Release notes entry updated:

ijklam avatar Aug 11 '24 09:08 ijklam

:heavy_exclamation_mark: Release notes required


:white_check_mark: Found changes and release notes in following paths:

Change path Release notes path Description
LanguageFeatures.fsi docs/release-notes/.Language/preview.md

github-actions[bot] avatar Aug 11 '24 09:08 github-actions[bot]

Here I encounter a problem about #line. For example, the code is saved in D:\Program.fs:

#1 "C:\\Program.fs"
System.ArgumentNullException.ThrowIfNullOrWhiteSpace("   ")  // will failed to build

// And more complicated case, repeat the file name and line number
#1 "C:\\Program.fs"
System.ArgumentNullException.ThrowIfNullOrWhiteSpace("   ")  // will failed to build

So here I want to get the original range instead of a range modified by #line . Is there anybody know how to do it?

ijklam avatar Aug 11 '24 16:08 ijklam

Thank you @ijklam , this looks good. Please follow https://github.com/dotnet/fsharp/blob/e4950e6c3f4f7e9829dd86f127a0e7cf54d9220e/DEVGUIDE.md?plain=1#L266 to verify and update the ilverify baselines, since some changes have been detected for this PR.

I will review this PR more deeply later this week.

T-Gro avatar Mar 10 '25 15:03 T-Gro

There are some problem with the #line therefore turn it into draft.

ijklam avatar Mar 14 '25 05:03 ijklam

This is ready for both the fsc and fsi, but may not work properly with the #line directive.

The #line directive processing needs LineMaps of #18049 to be available.

ijklam avatar Mar 25 '25 11:03 ijklam

I propose to merge this in as is with the #line limitation, afterall it is a construct for code generators.

This PR does come under a LanguageFeature flag and we could offer the feature for real world testing under the preview version.

T-Gro avatar Mar 25 '25 17:03 T-Gro

Hi there, I've make some efforts to make it get the source code from the LexBuffer and pass it to the cenv. Now it won't read files twice, and some parser functions in ParseAndCheckInputs.fs now return ParsedInput * ISourceText option, some checker functions also need a ISourceText option as input. I created a new field cenv.SourceText: ISourceText option besides the cenv.tcSink.CurrentSink.CurrentSourceText to store the source content, as the cenv.tcSink is seems to be used only in language service scenario.

ijklam avatar Apr 19 '25 16:04 ijklam

Turn this into draft until we make it compatible with the #lines.

ijklam avatar May 15 '25 09:05 ijklam

@T-Gro Hi there, I cannot access the Azure to see the test result. Could you please grant me the permission?

The page said:

The selected user account does not exist in the tenant "Microsoft" and cannot access the application "499b84ac-1321-427f-aa17-267ca6975798" in that tenant. You need to add the account as an external user of the tenant first. Please use a different account.

ijklam avatar Sep 04 '25 14:09 ijklam

@ijklam I see there are some timeouts in .Net Framework test runs, probably the cause is this https://github.com/dotnet/fsharp/pull/18875, so unrelated to your code. (threadpool starvation likely).

majocha avatar Sep 04 '25 17:09 majocha