@@ -3523,32 +3523,23 @@ bindingPattern:
35233523 | headBindingPattern
35243524 { $1, $1.Range }
35253525
3526- // This rule unifies the pattern parsing for both regular 'let' bindings and (let!, use!, and!)
3527- bindingPatternWithOptType:
3528- | headBindingPattern opt_topReturnTypeWithTypeConstraints
3529- { // Pattern with optional type annotation
3530- match $2 with
3531- | None ->
3532- // No type annotation
3533- $1, $1.Range, None
3534- | Some(colonRangeOpt, SynReturnInfo((ty, _), _)) ->
3535- // Pattern with type annotation (e.g., x: int)
3536- let mWhole = unionRanges $1.Range ty.Range
3537- let typedPat = SynPat.Typed($1, ty, mWhole)
3538- typedPat, mWhole, Some ty }
3539-
3540- // Handles the pattern part of let!, use!, and! bindings
3526+ // Handles pattern and return type part of let!, use!, and! bindings
35413527ceBindingCore:
3542- | opt_inline opt_mutable bindingPatternWithOptType
3543- { let pat, mPat, tyOpt = $3
3528+ | opt_inline opt_mutable bindingPattern opt_topReturnTypeWithTypeConstraints
3529+ { let pat, mPat = $3
3530+ let tyOpt = $4
35443531 let isInline = Option.isSome $1
35453532 let isMutable = Option.isSome $2
3546- match tyOpt with
3547- | Some ty ->
3548- parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.AllowTypedLetUseAndBang ty.Range
3549- | None -> ()
3550-
3551- pat, mPat, isInline, isMutable, tyOpt }
3533+
3534+ let ty =
3535+ match tyOpt with
3536+ | Some(colonRangeOpt, SynReturnInfo((ty, _), tym)) ->
3537+ parseState.LexBuffer.CheckLanguageFeatureAndRecover LanguageFeature.AllowTypedLetUseAndBang ty.Range
3538+ Some (SynBindingReturnInfo(ty, tym, [], { ColonRange = colonRangeOpt }))
3539+ | None ->
3540+ None
3541+
3542+ pat, mPat, isInline, isMutable, ty }
35523543
35533544opt_simplePatterns:
35543545 | simplePatterns
@@ -4144,7 +4135,7 @@ recover:
41444135
41454136moreBinders:
41464137 | AND_BANG ceBindingCore EQUALS typedSequentialExprBlock IN moreBinders %prec expr_let
4147- { let pat, mPat, isInline, isMutable, tyOpt = $2
4138+ { let pat, mPat, isInline, isMutable, returnInfo = $2
41484139
41494140 // and! bindings don't support inline or mutable modifiers
41504141 if isInline then errorR(Error(FSComp.SR.parsInvalidDeclarationSyntax(), rhs parseState 2))
@@ -4155,11 +4146,11 @@ moreBinders:
41554146 let m = unionRanges mKeyword $4.Range
41564147 let mIn = Some(rhs parseState 5)
41574148
4158- mkAndBang(mKeyword, pat, $4, m, mEquals, mIn) :: $6 }
4149+ mkAndBang(mKeyword, pat, returnInfo, $4, m, mEquals, mIn) :: $6 }
41594150
41604151 | OAND_BANG ceBindingCore EQUALS typedSequentialExprBlock hardwhiteDefnBindingsTerminator opt_OBLOCKSEP moreBinders %prec expr_let
41614152 { // Offside-sensitive version of and! binding
4162- let pat, mPat, isInline, isMutable, tyOpt = $2
4153+ let pat, mPat, isInline, isMutable, returnInfo = $2
41634154
41644155 // and! bindings don't support inline or mutable modifiers
41654156 if isInline then errorR(Error(FSComp.SR.parsInvalidDeclarationSyntax(), rhs parseState 2))
@@ -4171,7 +4162,7 @@ moreBinders:
41714162 let mEquals = rhs parseState 3
41724163 let m = unionRanges mKeyword $4.Range
41734164
4174- mkAndBang(mKeyword, pat, $4, m, mEquals, mIn) :: $7 }
4165+ mkAndBang(mKeyword, pat, returnInfo, $4, m, mEquals, mIn) :: $7 }
41754166
41764167 | %prec prec_no_more_attr_bindings
41774168 { [] }
@@ -4536,7 +4527,7 @@ declExpr:
45364527
45374528 | BINDER ceBindingCore EQUALS typedSequentialExprBlock IN opt_OBLOCKSEP moreBinders typedSequentialExprBlock %prec expr_let
45384529 { // Handle let! and use! bindings with unified pattern parsing
4539- let pat, mPat, isInline, isMutable, tyOpt = $2
4530+ let pat, mPat, isInline, isMutable, returnInfo = $2
45404531
45414532 // let! and use! bindings don't support inline or mutable modifiers
45424533 if isInline then errorR(Error(FSComp.SR.parsInvalidDeclarationSyntax(), rhs parseState 2))
@@ -4549,11 +4540,11 @@ declExpr:
45494540 // $1 contains the actual keyword ("let" or "use")
45504541 let isUse = ($1 = "use")
45514542
4552- mkLetExpression(true, None, m, $8, None, Some(pat, $4, $7, mKeyword, mEquals, isUse)) }
4543+ mkLetExpression(true, None, m, $8, None, Some(pat, returnInfo, $4, $7, mKeyword, mEquals, isUse)) }
45534544
45544545 | OBINDER ceBindingCore EQUALS typedSequentialExprBlock hardwhiteDefnBindingsTerminator opt_OBLOCKSEP moreBinders typedSequentialExprBlock %prec expr_let
45554546 { // Offside-sensitive version of let!/use! binding
4556- let pat, mPat, isInline, isMutable, tyOpt = $2
4547+ let pat, mPat, isInline, isMutable, returnInfo = $2
45574548
45584549 // let! and use! bindings don't support inline or mutable modifiers
45594550 if isInline then errorR(Error(FSComp.SR.parsInvalidDeclarationSyntax(), rhs parseState 2))
@@ -4567,12 +4558,12 @@ declExpr:
45674558
45684559 let isUse = ($1 = "use")
45694560
4570- mkLetExpression(true, None, m, $8, None, Some(pat, $4, $7, mKeyword, mEquals, isUse)) }
4561+ mkLetExpression(true, None, m, $8, None, Some(pat, returnInfo, $4, $7, mKeyword, mEquals, isUse)) }
45714562
45724563 | OBINDER ceBindingCore EQUALS typedSequentialExprBlock hardwhiteDefnBindingsTerminator opt_OBLOCKSEP error %prec expr_let
45734564 { // Error recovery for incomplete let!/use! bindings
45744565 // Allows intellisense to work when writing incomplete computation expressions
4575- let pat, mPat, isInline, isMutable, tyOpt = $2
4566+ let pat, mPat, isInline, isMutable, returnInfo = $2
45764567
45774568 // Error checking for invalid modifiers
45784569 if isInline then errorR(Error(FSComp.SR.parsInvalidDeclarationSyntax(), rhs parseState 2))
@@ -4586,7 +4577,7 @@ declExpr:
45864577 let isUse = ($1 = "use")
45874578
45884579 // Use ImplicitZero as the continuation expression for error recovery
4589- mkLetExpression(true, None, mAll, SynExpr.ImplicitZero m, None, Some(pat, $4, [], mKeyword, mEquals, isUse)) }
4580+ mkLetExpression(true, None, mAll, SynExpr.ImplicitZero m, None, Some(pat, returnInfo, $4, [], mKeyword, mEquals, isUse)) }
45904581
45914582 | DO_BANG typedSequentialExpr IN opt_OBLOCKSEP typedSequentialExprBlock %prec expr_let
45924583 { let spBind = DebugPointAtBinding.NoneAtDo
0 commit comments