@@ -3742,12 +3742,26 @@ let (|SpecificUnopExpr|_|) g vrefReqd expr =
37423742 | UnopExpr g ( vref, arg1) when valRefEq g vref vrefReqd -> Some arg1
37433743 | _ -> None
37443744
3745- let (| SignedIntegerConstExpr | _ |) expr =
3745+ let (| SignedConstExpr | _ |) expr =
37463746 match expr with
37473747 | Expr.Const ( Const.Int32 _, _, _)
37483748 | Expr.Const ( Const.SByte _, _, _)
37493749 | Expr.Const ( Const.Int16 _, _, _)
3750- | Expr.Const ( Const.Int64 _, _, _) -> Some ()
3750+ | Expr.Const ( Const.Int64 _, _, _)
3751+ | Expr.Const ( Const.Single _, _, _)
3752+ | Expr.Const ( Const.Double _, _, _) -> Some ()
3753+ | _ -> None
3754+
3755+ let (| IntegerConstExpr | _ |) expr =
3756+ match expr with
3757+ | Expr.Const ( Const.Int32 _, _, _)
3758+ | Expr.Const ( Const.SByte _, _, _)
3759+ | Expr.Const ( Const.Int16 _, _, _)
3760+ | Expr.Const ( Const.Int64 _, _, _)
3761+ | Expr.Const ( Const.Byte _, _, _)
3762+ | Expr.Const ( Const.UInt16 _, _, _)
3763+ | Expr.Const ( Const.UInt32 _, _, _)
3764+ | Expr.Const ( Const.UInt64 _, _, _) -> Some ()
37513765 | _ -> None
37523766
37533767let (| SpecificBinopExpr | _ |) g vrefReqd expr =
@@ -9672,7 +9686,7 @@ let EvalArithShiftOp (opInt8, opInt16, opInt32, opInt64, opUInt8, opUInt16, opUI
96729686 | _ -> error ( Error ( FSComp.SR.tastNotAConstantExpression(), m))
96739687 with :? System.OverflowException -> error ( Error ( FSComp.SR.tastConstantExpressionOverflow(), m))
96749688
9675- let EvalArithUnOp ( opInt8 , opInt16 , opInt32 , opInt64 , opUInt8 , opUInt16 , opUInt32 , opUInt64 ) ( arg1 : Expr ) =
9689+ let EvalArithUnOp ( opInt8 , opInt16 , opInt32 , opInt64 , opUInt8 , opUInt16 , opUInt32 , opUInt64 , opSingle , opDouble ) ( arg1 : Expr ) =
96769690 // At compile-time we check arithmetic
96779691 let m = arg1.Range
96789692 try
@@ -9685,10 +9699,12 @@ let EvalArithUnOp (opInt8, opInt16, opInt32, opInt64, opUInt8, opUInt16, opUInt3
96859699 | Expr.Const ( Const.UInt16 x1, _, ty) -> Expr.Const ( Const.UInt16 ( opUInt16 x1), m, ty)
96869700 | Expr.Const ( Const.UInt32 x1, _, ty) -> Expr.Const ( Const.UInt32 ( opUInt32 x1), m, ty)
96879701 | Expr.Const ( Const.UInt64 x1, _, ty) -> Expr.Const ( Const.UInt64 ( opUInt64 x1), m, ty)
9702+ | Expr.Const ( Const.Single x1, _, ty) -> Expr.Const ( Const.Single ( opSingle x1), m, ty)
9703+ | Expr.Const ( Const.Double x1, _, ty) -> Expr.Const ( Const.Double ( opDouble x1), m, ty)
96889704 | _ -> error ( Error ( FSComp.SR.tastNotAConstantExpression(), m))
96899705 with :? System.OverflowException -> error ( Error ( FSComp.SR.tastConstantExpressionOverflow(), m))
96909706
9691- let EvalArithBinOp ( opInt8 , opInt16 , opInt32 , opInt64 , opUInt8 , opUInt16 , opUInt32 , opUInt64 ) ( arg1 : Expr ) ( arg2 : Expr ) =
9707+ let EvalArithBinOp ( opInt8 , opInt16 , opInt32 , opInt64 , opUInt8 , opUInt16 , opUInt32 , opUInt64 , opSingle , opDouble ) ( arg1 : Expr ) ( arg2 : Expr ) =
96929708 // At compile-time we check arithmetic
96939709 let m = unionRanges arg1.Range arg2.Range
96949710 try
@@ -9701,11 +9717,16 @@ let EvalArithBinOp (opInt8, opInt16, opInt32, opInt64, opUInt8, opUInt16, opUInt
97019717 | Expr.Const ( Const.UInt16 x1, _, ty), Expr.Const ( Const.UInt16 x2, _, _) -> Expr.Const ( Const.UInt16 ( opUInt16 x1 x2), m, ty)
97029718 | Expr.Const ( Const.UInt32 x1, _, ty), Expr.Const ( Const.UInt32 x2, _, _) -> Expr.Const ( Const.UInt32 ( opUInt32 x1 x2), m, ty)
97039719 | Expr.Const ( Const.UInt64 x1, _, ty), Expr.Const ( Const.UInt64 x2, _, _) -> Expr.Const ( Const.UInt64 ( opUInt64 x1 x2), m, ty)
9720+ | Expr.Const ( Const.Single x1, _, ty), Expr.Const ( Const.Single x2, _, _) -> Expr.Const ( Const.Single ( opSingle x1 x2), m, ty)
9721+ | Expr.Const ( Const.Double x1, _, ty), Expr.Const ( Const.Double x2, _, _) -> Expr.Const ( Const.Double ( opDouble x1 x2), m, ty)
97049722 | _ -> error ( Error ( FSComp.SR.tastNotAConstantExpression(), m))
97059723 with :? System.OverflowException -> error ( Error ( FSComp.SR.tastConstantExpressionOverflow(), m))
97069724
97079725// See also PostTypeCheckSemanticChecks.CheckAttribArgExpr, which must match this precisely
97089726let rec EvalAttribArgExpr g x =
9727+ let ignore ( _x : 'a ) = Unchecked.defaultof< 'a>
9728+ let ignore2 ( _x : 'a ) ( _y : 'a ) = Unchecked.defaultof< 'a>
9729+
97099730 match x with
97109731
97119732 // Detect standard constants
@@ -9739,40 +9760,61 @@ let rec EvalAttribArgExpr g x =
97399760 EvalAttribArgExpr g arg1
97409761 // Detect bitwise or of attribute flags
97419762 | AttribBitwiseOrExpr g ( arg1, arg2) ->
9742- EvalArithBinOp ((|||), (|||), (|||), (|||), (|||), (|||), (|||), (|||)) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
9763+ let v1 = EvalAttribArgExpr g arg1
9764+
9765+ match v1 with
9766+ | IntegerConstExpr ->
9767+ EvalArithBinOp ((|||), (|||), (|||), (|||), (|||), (|||), (|||), (|||), ignore2, ignore2) v1 ( EvalAttribArgExpr g arg2)
9768+ | _ ->
9769+ errorR ( Error ( FSComp.SR.tastNotAConstantExpression(), x.Range))
9770+ x
97439771 | SpecificBinopExpr g g.unchecked_ addition_ vref ( arg1, arg2) ->
97449772 // At compile-time we check arithmetic
97459773 let v1 , v2 = EvalAttribArgExpr g arg1, EvalAttribArgExpr g arg2
97469774 match v1, v2 with
9747- | Expr.Const ( Const.String x1, m, ty), Expr.Const ( Const.String x2, _, _) -> Expr.Const ( Const.String ( x1 + x2), m, ty)
9775+ | Expr.Const ( Const.String x1, m, ty), Expr.Const ( Const.String x2, _, _) ->
9776+ Expr.Const ( Const.String ( x1 + x2), m, ty)
9777+ | Expr.Const ( Const.Char x1, m, ty), Expr.Const ( Const.Char x2, _, _) ->
9778+ Expr.Const ( Const.Char ( x1 + x2), m, ty)
97489779 | _ ->
9749- EvalArithBinOp ( Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+)) v1 v2
9780+ EvalArithBinOp ( Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked .(+), Checked .(+) ) v1 v2
97509781 | SpecificBinopExpr g g.unchecked_ subtraction_ vref ( arg1, arg2) ->
9751- EvalArithBinOp ( Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-)) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
9782+ let v1 , v2 = EvalAttribArgExpr g arg1, EvalAttribArgExpr g arg2
9783+ match v1, v2 with
9784+ | Expr.Const ( Const.Char x1, m, ty), Expr.Const ( Const.Char x2, _, _) ->
9785+ Expr.Const ( Const.Char ( x1 - x2), m, ty)
9786+ | _ ->
9787+ EvalArithBinOp ( Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-)) v1 v2
97529788 | SpecificBinopExpr g g.unchecked_ multiply_ vref ( arg1, arg2) ->
9753- EvalArithBinOp ( Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*)) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
9789+ EvalArithBinOp ( Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked .(*), Checked .(*) ) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
97549790 | SpecificBinopExpr g g.unchecked_ division_ vref ( arg1, arg2) ->
9755- EvalArithBinOp ((/), (/), (/), (/), (/), (/), (/), (/)) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
9791+ EvalArithBinOp ((/), (/), (/), (/), (/), (/), (/), (/), (/), (/) ) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
97569792 | SpecificBinopExpr g g.unchecked_ modulus_ vref ( arg1, arg2) ->
9757- EvalArithBinOp ((%), (%), (%), (%), (%), (%), (%), (%)) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
9793+ EvalArithBinOp ((%), (%), (%), (%), (%), (%), (%), (%), (%), (%) ) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
97589794 | SpecificBinopExpr g g.bitwise_ shift_ left_ vref ( arg1, arg2) ->
97599795 EvalArithShiftOp ((<<<), (<<<), (<<<), (<<<), (<<<), (<<<), (<<<), (<<<)) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
97609796 | SpecificBinopExpr g g.bitwise_ shift_ right_ vref ( arg1, arg2) ->
97619797 EvalArithShiftOp ((>>>), (>>>), (>>>), (>>>), (>>>), (>>>), (>>>), (>>>)) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
97629798 | SpecificBinopExpr g g.bitwise_ and_ vref ( arg1, arg2) ->
9763- EvalArithBinOp ((&&&), (&&&), (&&&), (&&&), (&&&), (&&&), (&&&), (&&&)) ( EvalAttribArgExpr g arg1) ( EvalAttribArgExpr g arg2)
9799+ let v1 = EvalAttribArgExpr g arg1
9800+
9801+ match v1 with
9802+ | IntegerConstExpr ->
9803+ EvalArithBinOp ((&&&), (&&&), (&&&), (&&&), (&&&), (&&&), (&&&), (&&&), ignore2, ignore2) v1 ( EvalAttribArgExpr g arg2)
9804+ | _ ->
9805+ errorR ( Error ( FSComp.SR.tastNotAConstantExpression(), x.Range))
9806+ x
97649807 | SpecificUnopExpr g g.unchecked_ unary_ minus_ vref arg1 ->
97659808 let v1 = EvalAttribArgExpr g arg1
97669809
97679810 match v1 with
9768- | SignedIntegerConstExpr ->
9769- let ignore ( _x : 'a ) = Unchecked.defaultof< 'a>
9770- EvalArithUnOp ( Checked.(~-), Checked.(~-), Checked.(~-), Checked.(~-), ignore, ignore, ignore, ignore) v1
9811+ | SignedConstExpr ->
9812+ EvalArithUnOp ( Checked.(~-), Checked.(~-), Checked.(~-), Checked.(~-), ignore, ignore, ignore, ignore, Checked.(~-), Checked.(~-)) v1
97719813 | _ ->
97729814 errorR ( Error ( FSComp.SR.tastNotAConstantExpression(), v1.Range))
97739815 x
97749816 | SpecificUnopExpr g g.unchecked_ unary_ plus_ vref arg1 ->
9775- EvalArithUnOp ((~+), (~+), (~+), (~+), (~+), (~+), (~+), (~+)) ( EvalAttribArgExpr g arg1)
9817+ EvalArithUnOp ((~+), (~+), (~+), (~+), (~+), (~+), (~+), (~+), (~+), (~+) ) ( EvalAttribArgExpr g arg1)
97769818 | SpecificUnopExpr g g.unchecked_ unary_ not_ vref arg1 ->
97779819 match EvalAttribArgExpr g arg1 with
97789820 | Expr.Const ( Const.Bool value, m, ty) ->
0 commit comments