Skip to content

Fix single quote and space in F# pretty methods - #4969

Merged
Jakub Jareš (nohwnd) merged 1 commit into
microsoft:mainfrom
nohwnd:fix-single-quote-f#
Apr 9, 2024
Merged

Jakub Jareš (nohwnd) merged 1 commit into
microsoft:mainfrom
nohwnd:fix-single-quote-f#

Conversation

@nohwnd

Copy link
Copy Markdown
Member

Description

Whitespace is not valid in method names and the parser was not skipping over escaped single tick \', so the method name from F# ``don't pass`` would be output as 'don\'t pass' in CIL. And the parser would parse 'don\' as being quoted, and t pass as invalid method part because there is whitespace.

Related issue

Fix #4313

  • I have ensured that there is a previously discussed and approved issue.

@ghost
ghost requested a review from Amaury Levé (Evangelink) as a code owner April 9, 2024 10:31

ghost commented Apr 9, 2024

Copy link
Copy Markdown
Member Author

We don't check for any additional characters in to unparse the method name from CIL, so ``one \ two`` we appear as 'one \\ two' in CIL and its managed name will be one \\ two.

Leaving this for another issue, if someone can confirm this is causing problems, or confirm what are the exact rules that F# uses to escape those names.

/cc Vlad Zarytovskii (@vzarytovskii)

@ghost
ghost enabled auto-merge (squash) April 9, 2024 12:14

ghost commented Apr 9, 2024

Copy link
Copy Markdown
Member

I have run a few manual tests and here are the characters that gets transformed (not exhaustive list):

  • \ escaped as \\
  • ' escaped as \'
  • " escaped as \"
  • @ escaped as @5

I will look at more cases now.

ghost commented Apr 9, 2024

Copy link
Copy Markdown
Member Author

Moved the issue here: #4972 because this PR solves the part where discovery cannot finish. With this fix it produces a managed name, but still not a managed name that can be used to lookup the method by name via reflection, which is a different problem with a bigger scope.

@ghost
ghost disabled auto-merge April 9, 2024 12:42
@ghost
ghost merged commit 9ce6c03 into microsoft:main Apr 9, 2024

ghost commented Apr 9, 2024 •

Copy link
Copy Markdown
Member

FYI, found the exact grammar for it:

token ident =
| ident-text For example, myName1
| `` ( [^'`' '\n' '\r' '\t'] | '`' [^ '`' '\n' '\r' '\t'] )+ ``

I can find exact escaping rules if you'll remind me tomorrow :)

This was referenced Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test discovery problem when single quote is used in F# method name

3 participants