Skip to content

feat: add F# string literals so (* inside a string is not a comment opener - #737

Open
YuriNachos wants to merge 1 commit into
boyter:masterfrom
YuriNachos:YuriNachos/w1-scc
Open

feat: add F# string literals so (* inside a string is not a comment opener#737
YuriNachos wants to merge 1 commit into
boyter:masterfrom
YuriNachos:YuriNachos/w1-scc

Conversation

@YuriNachos

Copy link
Copy Markdown

Fixes scc mis-counting F# files where a (* inside a string literal opens a phantom multi-line comment.

Summary

  • Add F# string literals to languages.json (quotes was empty): regular "…" (escaped), verbatim @"…" (no escape), and triple-quoted """…""" (F# 5+, no escape, may span lines).
  • Regenerate processor/constants.go and LANGUAGES.md via go generate.
  • Add TestCountStatsFSharpStringHidesBlockComment proving a (* inside a string no longer eats the following code lines.

Root Cause

F# declares (* … *) as a multi-line comment but had an empty quotes array. scc's scanner only ignores comment delimiters while inside a declared string, so a (* inside any "…" string opened a real block comment that consumed every subsequent line as a comment until EOF or a stray *). A 5-line fixture reported Code=1, Comment=4 instead of Code=4, Comment=1.

F# string syntax per the F# language reference: regular "…", verbatim @"…", and triple-quoted """…""". Modelled on the existing C# @"…" and Boo/Cangjie """…""" entries.

Validation

  • go generate (regenerates constants.go + LANGUAGES.md, no diff)
  • go build ./...
  • go test -race ./...
  • go test -run TestCountStatsFSharpStringHidesBlockComment ./processor/ -v (red on master, green after fix)
  • 5-line reproducer now reports Code=4, Comment=1

I licence this contribution under the MIT licence.

…pener

F# declared (* *) as multi-line comments but left quotes empty, so a (*
inside any string opened a phantom block comment that swallowed the
following code lines. Append F#'s three string-literal forms to quotes
(regular, verbatim @", triple-quoted """) and regenerate the compiled-in
database. Add TestCountStatsFSharpStringHidesBlockComment proving a (*
inside a string no longer eats the following code lines.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L/complexity Low complexity M/size Normal or medium sized change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant