Skip to content
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

FS0193: internal error: startIndex cannot be larger than length of string. (Parameter 'startIndex') #18402

Open
IS4Code opened this issue Mar 24, 2025 · 0 comments
Labels
Area-Compiler-Syntax lexfilter, indentation and parsing Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@IS4Code
Copy link

IS4Code commented Mar 24, 2025

I have noticed some very strange behaviour related to line directives, which in some cases lead to compiler errors.

Repro steps
This exact piece of code shows the behaviour:

open System

# 10
FSharp.Core.ExtraTopLevelOperators.printfn "%s" "ab"

# 15



// end

Expected behavior

The code should compile fine and print ab when executed.

Actual behavior

FS0193:10: internal error: startIndex cannot be larger than length of string. (Parameter 'startIndex')

Also, very strangely, if I remove FSharp.Core.ExtraTopLevelOperators., I get another strange error:

FS0001:10: This expression was expected to have type
''a -> 'b'
but here has type
'unit'

And, if I instead replace it with do , I get:

FS0193:10: internal error: Index and length must refer to a location within the string. (Parameter 'length')

I don't think the particular sequences I replace it with matter, it seems to be more a line position thing.

Known workarounds

I did not manage to find a workaround that preserves the line information. I would certainly appreciate a solution that works for older compilers.

Related information

Tested on .NET SDK 9.0.201.
Examples:

@github-actions github-actions bot added this to the Backlog milestone Mar 24, 2025
@abonie abonie added Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Area-Compiler-Syntax lexfilter, indentation and parsing and removed Needs-Triage labels Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-Syntax lexfilter, indentation and parsing Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
Status: New
Development

No branches or pull requests

2 participants