Skip to content

Conversation

edgarfgp
Copy link
Contributor

@edgarfgp edgarfgp commented Oct 10, 2025

Description

Fixes #11873

Before

let f1 a a = ()
         ^
         Error: "'a' is bound twice in this pattern"
let f2 (a, b as c) c = ()
				   ^
				   Error: "'c' is bound twice in this pattern"

let f3 (a, b as c) a = ()
				   ^
				   No Error

After

let f1 a a = ()
         ^
         Error: "'a' is bound twice in this pattern"
let f2 (a, b as c) c = ()
				   ^
				   Error: "'c' is bound twice in this pattern"

let f3 (a, b as c) a = ()
				   ^
				   Error: "'a' is bound twice in this pattern"

Checklist

  • Test cases added
  • Release notes entry updated

Copy link
Contributor

github-actions bot commented Oct 10, 2025

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.0.md

match synSimplePats with
| SynSimplePats.SimplePats ([], _, m) ->
// Unit (): synthesize a hidden name and unify with unit
let id = ident("unitVar" + string takenNames.Count, m)
Copy link
Member

@auduchinok auduchinok Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a few tests showing that this won't clash with a real pattern named unitVar, i.e. something like the following works as expected, there's no error and the patterns are not considered to be same-named:

let (unitVar, ()) = 1, ()
let f unitVar () = ()
let f (unitVar, ()) = ()

Copy link
Contributor Author

@edgarfgp edgarfgp Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like 6375cd8 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also try to replicate the problem from the initial issue?

Copy link
Contributor Author

@edgarfgp edgarfgp Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I guess you mean adding a test for code shown in the #11873 .

let f1 a a = ()
let f2 (a, b as c) c = ()
let f3 (a, b as c) a = ()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 3a1028b

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please cover unitVar there in the cases that are fixed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in e6ea704

Copy link
Member

@auduchinok auduchinok Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edgarfgp You've added many tests, but none of them cover both 1) the initial issue about different pattern groups and 2) () and unitVar possibly being considered to have the same name (which would be a regression if there's a new error). This change introduces a possible regression and we need just one case to ensure it doesn't happen, but none of these additional tests seem to cover the actual change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 5488c00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Name is bound multiple times is not reported in 'as' pattern

2 participants