From b7cac12b9796ddb6a0b74f52fb6a33e529f63d61 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 14 Aug 2023 17:53:27 +0200 Subject: [PATCH] Use errorR intead of try with and use range helpers --- src/Compiler/Checking/CheckExpressions.fs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index f2a0877cace..1a146e9cf20 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -7418,15 +7418,12 @@ and TcRecdExpr cenv overallTy env tpenv (inherits, withExprOpt, synRecdFields, m | Some item -> CallNameResolutionSink cenv.tcSink (fldId.idRange, env.eNameResEnv, item, emptyTyparInst, ItemOccurence.UseInType, env.eAccessRights) | None -> () - - try - let firstPartRange = mkRange mWholeExpr.FileName mWholeExpr.Start (mkPos mWholeExpr.StartLine (mWholeExpr.StartColumn + 1)) - // Use the left { in the expression - error(Error(FSComp.SR.chkCopyUpdateSyntaxInAnonRecords(), firstPartRange)) - with _ -> - // Use the right } in the expression - let lastPartRange = mkRange mWholeExpr.FileName (mkPos mWholeExpr.StartLine (mWholeExpr.EndColumn - 1)) (mkPos mWholeExpr.StartLine (mWholeExpr.EndColumn)) - error(Error(FSComp.SR.chkCopyUpdateSyntaxInAnonRecords(), lastPartRange)) + let firstPartRange = withStartEnd mWholeExpr.Start (mkPos mWholeExpr.StartLine (mWholeExpr.StartColumn + 1)) mWholeExpr + // Use the left { in the expression + errorR(Error(FSComp.SR.chkCopyUpdateSyntaxInAnonRecords(), firstPartRange)) + // Use the right } in the expression + let lastPartRange = withStartEnd (mkPos mWholeExpr.StartLine (mWholeExpr.EndColumn - 1)) (mkPos mWholeExpr.StartLine mWholeExpr.EndColumn) mWholeExpr + errorR(Error(FSComp.SR.chkCopyUpdateSyntaxInAnonRecords(), lastPartRange)) [] else // If the overall type is a record type build a map of the fields