diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 6f6aa0d6b70..08f3104203b 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -4658,7 +4658,6 @@ and TcIntersectionConstraint (cenv: cenv) env newOk checkConstraints occ tpenv s ) tpenv let tpTy = tp.AsType KnownAmbivalentToNull // TODO: NULLNESS - tpTy, tpenv and TcTypeStaticConstant kindOpt tpenv c m = diff --git a/src/Compiler/Checking/ConstraintSolver.fs b/src/Compiler/Checking/ConstraintSolver.fs index 2f8915d6846..d624abf78c5 100644 --- a/src/Compiler/Checking/ConstraintSolver.fs +++ b/src/Compiler/Checking/ConstraintSolver.fs @@ -4091,4 +4091,4 @@ let IsApplicableMethApprox g amap m (minfo: MethInfo) availObjTy = |> CommitOperationResult | _ -> true else - true + true \ No newline at end of file diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 970bfd17624..34e202d5018 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -1289,6 +1289,7 @@ type Exception with | Parser.TOKEN_INTERP_STRING_END -> SR.GetString("Parser.TOKEN.INTERP.STRING.END") | Parser.TOKEN_WITHNULL__ -> SR.GetString("Parser.TOKEN.WITHNULL__") | Parser.TOKEN_NOTNULL__ -> SR.GetString("Parser.TOKEN.NOTNULL__") + | Parser.TOKEN_BAR_JUST_BEFORE_NULL -> SR.GetString("Parser.TOKEN.BAR_JUST_BEFORE_NULL") | unknown -> let result = sprintf "unknown token tag %+A" unknown Debug.Assert(false, result) diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index ffcf00b5784..3af0391078c 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -426,6 +426,9 @@ symbol '|}' + + symbol '|' (directly before 'null') + symbol '>}' diff --git a/src/Compiler/Service/ServiceLexing.fs b/src/Compiler/Service/ServiceLexing.fs index 22fb8682f5a..c8f4797021c 100644 --- a/src/Compiler/Service/ServiceLexing.fs +++ b/src/Compiler/Service/ServiceLexing.fs @@ -395,6 +395,7 @@ module internal TokenClassifications = | MAYBENULL__ | NOTNULL__ | WITHNULL__ + | BAR_JUST_BEFORE_NULL | TYPE_COMING_SOON | TYPE_IS_HERE | MODULE_COMING_SOON diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index cd7e16c9b21..d17c27d7329 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -1123,10 +1123,11 @@ type LexFilterImpl ( // fx // fx // fx - // fx - // fx + // fx + // fx + // fx | DEFAULT | COLON | COLON_GREATER | STRUCT | NULL | DELEGATE | AND | WHEN | AMP - | NOTNULL__ | MAYBENULL__ | WITHNULL__ + | NOTNULL__ | MAYBENULL__ | WITHNULL__ | BAR_JUST_BEFORE_NULL | DOT_DOT | NEW | LBRACE_BAR @@ -2438,6 +2439,9 @@ type LexFilterImpl ( pool.Return tokenTup hwTokenFetch useBlockRule + | BAR, _ when (lexbuf.SupportsFeature(LanguageFeature.NullnessChecking) && match peekNextToken() with NULL -> true | _ -> false) -> + returnToken tokenLexbufState BAR_JUST_BEFORE_NULL + // Ordinary tokens start a vanilla block | _, CtxtSeqBlock _ :: _ -> pushCtxt tokenTup (CtxtVanilla(tokenStartPos, isLongIdentEquals token)) diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index f6dff65edd1..7ff2fe76510 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -89,7 +89,7 @@ let parse_error_rich = Some(fun (ctxt: ParseErrorContext<_>) -> %token GREATER_RBRACK STRUCT SIG %token STATIC MEMBER CLASS ABSTRACT OVERRIDE DEFAULT CONSTRUCTOR INHERIT %token EXTERN VOID PUBLIC PRIVATE INTERNAL GLOBAL -%token MAYBENULL__ NOTNULL__ WITHNULL__ +%token MAYBENULL__ NOTNULL__ WITHNULL__ BAR_JUST_BEFORE_NULL /* for parser 'escape hatch' out of expression context without consuming the 'recover' token */ %token TYPE_COMING_SOON TYPE_IS_HERE MODULE_COMING_SOON MODULE_IS_HERE @@ -256,6 +256,7 @@ let parse_error_rich = Some(fun (ctxt: ParseErrorContext<_>) -> /* Lower than "if a then b" */ %left prec_then_before %nonassoc prec_then_if +%nonassoc BAR_JUST_BEFORE_NULL %left BAR %right SEMICOLON prec_semiexpr_sep OBLOCKSEP @@ -971,11 +972,11 @@ classMemberSpfn: let trivia: SynMemberSigMemberTrivia = { GetSetKeywords = getSetRangeOpt } SynMemberSig.Member(valSpfn, flags, mWhole, trivia) } - | opt_attributes opt_access interfaceMember appType + | opt_attributes opt_access interfaceMember appTypeWithoutNull { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) SynMemberSig.Interface($4, unionRanges (rhs parseState 3) ($4).Range) } - | opt_attributes opt_access INHERIT appType + | opt_attributes opt_access INHERIT appTypeWithoutNull { if Option.isSome $2 then errorR (Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) SynMemberSig.Inherit($4, unionRanges (rhs parseState 1) $4.Range) } @@ -1356,7 +1357,7 @@ openDecl: { let mOpen = rhs parseState 1 SynOpenDeclTarget.ModuleOrNamespace(SynLongIdent([], [], []), mOpen.EndRange), mOpen } - | OPEN typeKeyword appType + | OPEN typeKeyword appTypeWithoutNull { let mOpen = rhs parseState 1 let mPath = $3.Range SynOpenDeclTarget.Type($3, mPath), unionRanges mOpen mPath } @@ -1603,12 +1604,9 @@ tyconDefn: let (tcDefRepr, mWith, members) = $8 nameRange let (SynComponentInfo(_, _, _, lid, _, _, _, _)) = $1 let mEquals = rhs parseState 7 - // Gets the XML doc comments prior to the implicit constructor let xmlDoc = grabXmlDoc (parseState, $2, 2) - let m = match lid with [] -> rhs parseState 1 | _ -> rangeOfLid lid - let memberCtorPattern = spats |> Option.map (fun spats -> SynMemberDefn.ImplicitCtor(vis, $2, spats, Option.bind snd az, xmlDoc, m, { AsKeyword = Option.map fst az }) @@ -1636,14 +1634,11 @@ tyconDefn: | Some(_, Some id) -> reportParseErrorAt (rhs parseState 6) (FSComp.SR.tcLetAndDoRequiresImplicitConstructionSequence ()) | _ -> () - tcDefRepr - let declRange = unionRanges (rhs parseState 1) tcDefRepr.Range let mWhole = (declRange, members) ||> unionRangeWithListBy (fun (mem: SynMemberDefn) -> mem.Range) |> unionRangeWithXmlDoc xmlDoc - fun leadingKeyword -> let trivia: SynTypeDefnTrivia = { LeadingKeyword = leadingKeyword; EqualsRange = Some mEquals; WithKeyword = mWith } SynTypeDefn($1, tcDefRepr, members, memberCtorPattern, mWhole, trivia) } @@ -1660,7 +1655,6 @@ tyconDefn: | Some spats, _, _ -> let memberCtorPattern = SynMemberDefn.ImplicitCtor(vis, $2, spats, Option.bind snd az, xmlDoc, m, { AsKeyword = Option.map fst az }) [memberCtorPattern], unionRanges mName memberCtorPattern.Range - | _, _, Some(mAs, asId) -> let mAs = asId |> Option.map (fun id -> @@ -1668,12 +1662,9 @@ tyconDefn: id.idRange ) |> Option.defaultValue mAs - [], unionRanges mName mAs - | _, Some vis, _ -> [], unionRanges mName vis.Range - | _ -> [], mName @@ -1681,7 +1672,6 @@ tyconDefn: let trivia = { SynTypeDefnTrivia.Zero with LeadingKeyword = leadingKeyword } SynTypeDefn($1, SynTypeDefnRepr.Simple(SynTypeDefnSimpleRepr.None(mName), mName), members, None, mWhole, trivia) } - /* The right-hand-side of a type definition */ tyconDefnRhsBlock: /* This rule allows members to be given for record and union types in the #light syntax */ @@ -1998,7 +1988,7 @@ classDefnMember: [SynMemberDefn.Member(binding, mWhole)] } - | opt_attributes opt_access interfaceMember appType opt_interfaceImplDefn + | opt_attributes opt_access interfaceMember appTypeWithoutNull opt_interfaceImplDefn { if not (isNil $1) then errorR(Error(FSComp.SR.parsAttributesAreNotPermittedOnInterfaceImplementations(), rhs parseState 1)) if Option.isSome $2 then errorR(Error(FSComp.SR.parsInterfacesHaveSameVisibilityAsEnclosingType(), rhs parseState 3)) let mWithKwd, members, mWhole = @@ -2389,12 +2379,12 @@ tyconDefnOrSpfnSimpleRepr: | opt_attributes opt_access path LQUOTE STRING recover { errorR(Error(FSComp.SR.parsUnexpectedQuotationOperatorInTypeAliasDidYouMeanVerbatimString(), rhs parseState 4)) SynTypeDefnSimpleRepr.TypeAbbrev(ParserDetail.ErrorRecovery, SynType.LongIdent($3), unionRanges (rhs parseState 1) $3.Range) } - - /* A type abbreviation */ + + /* A type abbreviation */ | opt_attributes opt_access typ { if not (isNil $1) then errorR(Error(FSComp.SR.parsAttributesIllegalHere(), rhs parseState 1)) if Option.isSome $2 then errorR(Error(FSComp.SR.parsTypeAbbreviationsCannotHaveVisibilityDeclarations(), rhs parseState 2)) - SynTypeDefnSimpleRepr.TypeAbbrev(ParserDetail.Ok, $3, unionRanges (rhs parseState 1) $3.Range) } + SynTypeDefnSimpleRepr.TypeAbbrev(ParserDetail.Ok, $3, unionRanges (rhs parseState 1) $3.Range) } /* A union type definition */ | opt_attributes opt_access unionTypeRepr @@ -2607,6 +2597,13 @@ typeConstraint: | typar COLON NOTNULL__ { SynTypeConstraint.WhereTyparNotSupportsNull($1, lhs parseState) } + | typar COLON IDENT NULL + { if $3 <> "not" then reportParseErrorAt (rhs parseState 3) (FSComp.SR.parsUnexpectedIdentifier($3 + " (2)")) + SynTypeConstraint.WhereTyparNotSupportsNull($1, lhs parseState) } + + | typar COLON NOTNULL__ + { SynTypeConstraint.WhereTyparNotSupportsNull($1, lhs parseState) } + | typar COLON LPAREN classMemberSpfn rparen { let tp = $1 SynTypeConstraint.WhereTyparSupportsMember(SynType.Var(tp, tp.Range), $4, lhs parseState) } @@ -2634,16 +2631,16 @@ typeConstraint: | "unmanaged" -> SynTypeConstraint.WhereTyparIsUnmanaged($1, lhs parseState) | nm -> raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsUnexpectedIdentifier(nm + " (4)")) } - | appType + | appTypeWithoutNull { SynTypeConstraint.WhereSelfConstrained($1, lhs parseState) } typeAlts: - | typeAlts OR appType + | typeAlts OR appTypeWithoutNull { let mOr = rhs parseState 2 let m = unionRanges $1.Range $3.Range SynType.Or($1, $3, m, { OrKeyword = mOr }) } - | appType + | appTypeWithoutNull { $1 } /* The core of a union type definition */ @@ -2753,6 +2750,13 @@ firstUnionCaseDecl: let mDecl = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc Choice2Of2(SynUnionCase([], SynIdent($1, None), SynUnionCaseKind.Fields $3, xmlDoc, None, mDecl, trivia)) } + | unionCaseName COLON topType + { if parseState.LexBuffer.ReportLibraryOnlyFeatures then libraryOnlyWarning(lhs parseState) + let trivia: SynUnionCaseTrivia = { BarRange = None } + let xmlDoc = grabXmlDoc (parseState, [], 1) + let mDecl = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc + Choice2Of2(SynUnionCase([], $1, SynUnionCaseKind.FullType $3, xmlDoc, None, mDecl, trivia)) } + | ident OF recover { let trivia: SynUnionCaseTrivia = { BarRange = None } let xmlDoc = grabXmlDoc (parseState, [], 1) @@ -2784,12 +2788,12 @@ unionCaseReprElements: { [$1] } unionCaseReprElement: - | ident COLON appType + | ident COLON appTypeNullableInParens { let xmlDoc = grabXmlDoc(parseState, [], 1) let mWhole = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc mkSynNamedField ($1, $3, xmlDoc, mWhole) } - | appType + | appTypeNullableInParens { let xmlDoc = grabXmlDoc(parseState, [], 1) mkSynAnonField ($1, xmlDoc) } @@ -3114,6 +3118,9 @@ cType: | cType WITHNULL__ { SynType.WithNull($1, false, lhs parseState) } + | cType BAR_JUST_BEFORE_NULL NULL + { SynType.WithNull($1, false, lhs parseState) } + | cType AMP { let m = lhs parseState SynType.App(SynType.LongIdent(SynLongIdent([ident("byref", m)], [], [ Some(IdentTrivia.OriginalNotation "&") ])), None, [$1], [], None, true, m) } @@ -3440,12 +3447,18 @@ simplePatterns: let simplePats, _ = SimplePatsOfPat parseState.SynArgNameGenerator pat simplePats } +barCanBeRightBeforeNull: + | BAR + { } + | BAR_JUST_BEFORE_NULL + { } + headBindingPattern: - | headBindingPattern AS constrPattern + | headBindingPattern AS constrPattern %prec AS { SynPat.As($1, $3, rhs2 parseState 1 3) } - | headBindingPattern BAR headBindingPattern + | headBindingPattern barCanBeRightBeforeNull headBindingPattern %prec BAR { let mBar = rhs parseState 2 SynPat.Or($1, $3, rhs2 parseState 1 3, { BarRange = mBar }) } @@ -3716,10 +3729,10 @@ parenPatternBody: /* duplicating the entire expression grammar, or making a fairly severe breaking change */ /* to the language. */ parenPattern: - | parenPattern AS constrPattern + | parenPattern AS constrPattern %prec AS { SynPat.As($1, $3, rhs2 parseState 1 3) } - | parenPattern BAR parenPattern + | parenPattern barCanBeRightBeforeNull parenPattern %prec BAR { let mBar = rhs parseState 2 SynPat.Or($1, $3, rhs2 parseState 1 3, { BarRange = mBar }) } @@ -4615,11 +4628,11 @@ withPatternClauses: | patternClauses { $1 None } - | BAR patternClauses + | barCanBeRightBeforeNull patternClauses { let mBar = rhs parseState 1 |> Some $2 mBar } - | BAR error + | barCanBeRightBeforeNull error { // silent recovery let mLast = rhs parseState 1 [], mLast } @@ -4643,7 +4656,7 @@ patternClauses: fun mBar -> [SynMatchClause(pat, guard, resultExpr, m, DebugPointAtTarget.Yes, { ArrowRange = Some mArrow; BarRange = mBar })], mLast } - | patternAndGuard patternResult BAR patternClauses + | patternAndGuard patternResult barCanBeRightBeforeNull patternClauses { let pat, guard = $1 let mArrow, resultExpr = $2 let mNextBar = rhs parseState 3 |> Some @@ -4652,7 +4665,7 @@ patternClauses: fun mBar -> (SynMatchClause(pat, guard, resultExpr, m, DebugPointAtTarget.Yes, { ArrowRange = Some mArrow; BarRange = mBar }) :: clauses), mLast } - | patternAndGuard error BAR patternClauses + | patternAndGuard error barCanBeRightBeforeNull patternClauses { let pat, guard = $1 let mNextBar = rhs parseState 3 |> Some let clauses, mLast = $4 mNextBar @@ -4661,7 +4674,7 @@ patternClauses: fun _mBar -> (SynMatchClause(pat, guard, arbExpr ("patternClauses1", m.EndRange), m, DebugPointAtTarget.Yes, SynMatchClauseTrivia.Zero) :: clauses), mLast } - | patternAndGuard patternResult BAR recover + | patternAndGuard patternResult barCanBeRightBeforeNull recover { let pat, guard = $1 let mArrow, resultExpr = $2 let mLast = rhs parseState 3 @@ -5198,9 +5211,10 @@ typars: SynType.Paren($2, m) } typarAlts: - | typarAlts OR appType + | typarAlts OR appTypeCanBeNullable { let mOr = rhs parseState 2 - let m = unionRanges $1.Range $3.Range + let appType : SynType = $3 + let m = unionRanges $1.Range appType.Range SynType.Or($1, $3, m, { OrKeyword = mOr }) } | typar @@ -5533,7 +5547,7 @@ opt_objExprInterfaces: { (* silent recovery *) $2 } objExprInterface: - | interfaceMember appType opt_objExprBindings opt_declEnd opt_OBLOCKSEP + | interfaceMember appTypeWithoutNull opt_objExprBindings opt_declEnd opt_OBLOCKSEP { let mWithKwd, bindings, members = $3 let m = match List.tryLast members with @@ -5755,14 +5769,14 @@ topTupleTypeElements: [ SynTupleTypeSegment.Type t, Some argInfo ] } topAppType: - | attributes appType COLON appType + | attributes appTypeCanBeNullable COLON appTypeCanBeNullable { match $2 with | SynType.LongIdent(SynLongIdent([id], _, _)) -> let m = unionRanges (rhs parseState 1) $4.Range SynType.SignatureParameter($1, false, Some id, $4, m), SynArgInfo($1, false, Some id) | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) } - | attributes appType COLON recover + | attributes appTypeCanBeNullable COLON recover { match $2 with | SynType.LongIdent(SynLongIdent([id], _, _)) -> let mColon = rhs parseState 2 @@ -5771,7 +5785,7 @@ topAppType: SynType.SignatureParameter($1, false, Some id, ty, m), SynArgInfo($1, false, Some id) | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) } - | attributes QMARK ident COLON appType + | attributes QMARK ident COLON appTypeCanBeNullable { let m = unionRanges (rhs parseState 1) $5.Range SynType.SignatureParameter($1, true, Some $3, $5, m), SynArgInfo($1, true, Some $3) } @@ -5781,18 +5795,18 @@ topAppType: let ty = SynType.FromParseError(mColon.EndRange) SynType.SignatureParameter($1, true, Some $3, ty, m), SynArgInfo($1, true, Some $3) } - | attributes appType + | attributes appTypeCanBeNullable { let m = unionRanges (rhs parseState 1) $2.Range SynType.SignatureParameter($1, false, None, $2, m), SynArgInfo($1, false, None) } - | appType COLON appType + | appTypeCanBeNullable COLON appTypeCanBeNullable { match $1 with | SynType.LongIdent(SynLongIdent([id], _, _)) -> let m = unionRanges (rhs parseState 1) $3.Range SynType.SignatureParameter([], false, Some id, $3, m), SynArgInfo([], false, Some id) | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) } - | appType COLON recover + | appTypeCanBeNullable COLON recover { match $1 with | SynType.LongIdent(SynLongIdent([id], _, _)) -> let mColon = rhs parseState 2 @@ -5801,7 +5815,7 @@ topAppType: SynType.SignatureParameter([], false, Some id, ty, m), SynArgInfo([], false, Some id) | _ -> raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsSyntaxErrorInLabeledType()) } - | QMARK ident COLON appType + | QMARK ident COLON appTypeCanBeNullable { let m = unionRanges (rhs parseState 1) $4.Range SynType.SignatureParameter([], true, Some $2, $4, m), SynArgInfo([], true, Some $2) } @@ -5811,22 +5825,22 @@ topAppType: let ty = SynType.FromParseError(mColon.EndRange) SynType.SignatureParameter([], true, Some $2, ty, m), SynArgInfo([], true, Some $2) } - | appType + | appTypeCanBeNullable { $1, SynArgInfo([], false, None) } /* Grammar rule meant for recovery scenarios */ /* For example in unionCaseReprElement where function type is not allowed */ invalidUseOfAppTypeFunction: - | appType RARROW invalidUseOfAppTypeFunction + | appTypeWithoutNull RARROW invalidUseOfAppTypeFunction { let mArrow = rhs parseState 2 let m = unionRanges (rhs2 parseState 1 2) $3.Range SynType.Fun($1, $3, m, { ArrowRange = mArrow }) } - | appType RARROW recover + | appTypeWithoutNull RARROW recover { let mArrow = rhs parseState 2 let ty = SynType.FromParseError(mArrow.EndRange) let m = rhs2 parseState 1 2 SynType.Fun($1, ty, m, { ArrowRange = mArrow }) } - | appType RARROW RARROW invalidUseOfAppTypeFunction + | appTypeWithoutNull RARROW RARROW invalidUseOfAppTypeFunction { let mArrow1 = rhs parseState 2 let mArrow2 = rhs parseState 3 reportParseErrorAt mArrow2 (FSComp.SR.parsExpectingType ()) @@ -5834,7 +5848,7 @@ invalidUseOfAppTypeFunction: let m1 = unionRanges $1.Range $4.Range let m2 = unionRanges mArrow2 $4.Range SynType.Fun($1, SynType.Fun(ty, $4, m2, { ArrowRange = mArrow2 }), m1, { ArrowRange = mArrow1 }) } - | appType RARROW appType + | appTypeWithoutNull RARROW appTypeWithoutNull { let mArrow = rhs parseState 2 let m = rhs2 parseState 1 3 SynType.Fun($1, $3, m, { ArrowRange = mArrow }) } @@ -5870,12 +5884,12 @@ typEOF: tupleType: - | appType STAR tupleOrQuotTypeElements + | appTypeCanBeNullable STAR tupleOrQuotTypeElements { let mStar = rhs parseState 2 let path = SynTupleTypeSegment.Type $1 :: SynTupleTypeSegment.Star mStar :: $3 mkSynTypeTuple path } - | appType STAR recover + | appTypeCanBeNullable STAR recover { let mStar = rhs parseState 2 let ty = SynType.FromParseError(mStar.EndRange) let path = [SynTupleTypeSegment.Type $1; SynTupleTypeSegment.Star mStar; SynTupleTypeSegment.Type ty] @@ -5901,28 +5915,28 @@ tupleType: let path = [SynTupleTypeSegment.Slash mSlash; SynTupleTypeSegment.Type ty] mkSynTypeTuple path } - | appType INFIX_STAR_DIV_MOD_OP tupleOrQuotTypeElements + | appTypeCanBeNullable INFIX_STAR_DIV_MOD_OP tupleOrQuotTypeElements { if $2 <> "/" then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnexpectedInfixOperator()) let mSlash = rhs parseState 2 let path = SynTupleTypeSegment.Type $1 :: SynTupleTypeSegment.Slash mSlash :: $3 mkSynTypeTuple path } - | appType INFIX_STAR_DIV_MOD_OP recover + | appTypeCanBeNullable INFIX_STAR_DIV_MOD_OP recover { if $2 <> "/" then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnexpectedInfixOperator ()) let mSlash = rhs parseState 2 let ty = SynType.FromParseError(mSlash.EndRange) let path = [SynTupleTypeSegment.Type $1; SynTupleTypeSegment.Slash mSlash; SynTupleTypeSegment.Type ty] mkSynTypeTuple path } - | appType %prec prec_tuptyp_prefix + | appTypeCanBeNullable %prec prec_tuptyp_prefix { $1 } tupleOrQuotTypeElements: - | appType STAR tupleOrQuotTypeElements + | appTypeCanBeNullable STAR tupleOrQuotTypeElements { let mStar = rhs parseState 2 SynTupleTypeSegment.Type $1 :: SynTupleTypeSegment.Star mStar :: $3 } - | appType STAR recover + | appTypeCanBeNullable STAR recover { let mStar = rhs parseState 2 let ty = SynType.FromParseError(mStar.EndRange) [SynTupleTypeSegment.Type $1; SynTupleTypeSegment.Star mStar; SynTupleTypeSegment.Type ty] } @@ -5933,12 +5947,12 @@ tupleOrQuotTypeElements: reportParseErrorAt mStar (FSComp.SR.parsExpectingType ()) SynTupleTypeSegment.Type ty :: SynTupleTypeSegment.Star mStar :: $2 } - | appType INFIX_STAR_DIV_MOD_OP tupleOrQuotTypeElements + | appTypeCanBeNullable INFIX_STAR_DIV_MOD_OP tupleOrQuotTypeElements { if $2 <> "/" then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnexpectedInfixOperator ()) let mSlash = rhs parseState 2 SynTupleTypeSegment.Type $1 :: SynTupleTypeSegment.Slash mSlash :: $3 } - | appType INFIX_STAR_DIV_MOD_OP recover + | appTypeCanBeNullable INFIX_STAR_DIV_MOD_OP recover { if $2 <> "/" then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnexpectedInfixOperator ()) let mSlash = rhs parseState 2 let ty = SynType.FromParseError(mSlash.EndRange) @@ -5951,7 +5965,7 @@ tupleOrQuotTypeElements: reportParseErrorAt mSlash (FSComp.SR.parsExpectingType ()) SynTupleTypeSegment.Type ty :: SynTupleTypeSegment.Slash mSlash :: $2 } - | appType %prec prec_tuptyptail_prefix + | appTypeCanBeNullable %prec prec_tuptyptail_prefix { [ SynTupleTypeSegment.Type $1 ] } intersectionType: @@ -5983,25 +5997,40 @@ appTypeConPower: | appTypeCon { $1 } -appType: - | appType MAYBENULL__ +appTypeCanBeNullable: + | appTypeWithoutNull BAR_JUST_BEFORE_NULL NULL + { SynType.WithNull($1, false, lhs parseState) } + + | appTypeWithoutNull + { $1 } + +appTypeNullableInParens: + | appTypeWithoutNull + { $1 } + + | LPAREN appTypeCanBeNullable rparen + { SynType.Paren($2, lhs parseState) } + +appTypeWithoutNull: + | appTypeWithoutNull MAYBENULL__ { SynType.WithNull($1, true, lhs parseState) } - | appType WITHNULL__ + | appTypeWithoutNull WITHNULL__ { SynType.WithNull($1, false, lhs parseState) } /* - | appType QMARK + | appTypeWithoutNull QMARK { SynType.WithNull($1, false, lhs parseState) } */ - | appType arrayTypeSuffix + | appTypeWithoutNull arrayTypeSuffix + { SynType.Array($2, $1, lhs parseState) } - | appType HIGH_PRECEDENCE_BRACK_APP arrayTypeSuffix /* only HPA for "name[]" allowed here */ + | appTypeWithoutNull HIGH_PRECEDENCE_BRACK_APP arrayTypeSuffix /* only HPA for "name[]" allowed here */ { SynType.Array($3, $1, lhs parseState) } - | appType appTypeConPower + | appTypeWithoutNull appTypeConPower /* note: use "rhs parseState 1" to deal with parens in "(int) list" */ { SynType.App($2, None, [$1], [], None, true, unionRanges (rhs parseState 1) $2.Range) } @@ -6202,24 +6231,24 @@ atomType: { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedParen ()) SynType.Paren($2, lhs parseState) } - | STRUCT LPAREN appType STAR tupleOrQuotTypeElements rparen + | STRUCT LPAREN appTypeCanBeNullable STAR tupleOrQuotTypeElements rparen { let mStar = rhs parseState 4 let path = SynTupleTypeSegment.Type $3 :: SynTupleTypeSegment.Star mStar :: $5 let m = rhs2 parseState 1 6 SynType.Tuple(true, path, m) } - | STRUCT LPAREN appType STAR tupleOrQuotTypeElements recover + | STRUCT LPAREN appTypeCanBeNullable STAR tupleOrQuotTypeElements recover { reportParseErrorAt (rhs parseState 2) (FSComp.SR.parsUnmatchedParen()) let mStar = rhs parseState 4 let path = SynTupleTypeSegment.Type $3 :: SynTupleTypeSegment.Star mStar :: $5 let m = rhs2 parseState 1 5 SynType.Tuple(true, path, m) } - | STRUCT LPAREN appType STAR recover + | STRUCT LPAREN appTypeCanBeNullable STAR recover { reportParseErrorAt (rhs parseState 2) (FSComp.SR.parsUnmatchedParen()) SynType.Anon(lhs parseState) } - | STRUCT LPAREN appType recover + | STRUCT LPAREN appTypeCanBeNullable recover { reportParseErrorAt (rhs parseState 2) (FSComp.SR.parsUnmatchedParen()) SynType.Anon(lhs parseState) } @@ -6666,12 +6695,6 @@ deprecated_opt_equals: | EQUALS { deprecatedWithError (FSComp.SR.parsNoEqualShouldFollowNamespace()) (lhs parseState); () } | /* EMPTY */ { } -opt_equals: - | EQUALS - { let mEquals = rhs parseState 1 - Some mEquals } - | /* EMPTY */ { None } - opt_OBLOCKSEP: | OBLOCKSEP { } | /* EMPTY */ { } @@ -6684,10 +6707,6 @@ opt_rec: | REC { true } | /* EMPTY */ { false } -opt_bar: - | BAR { } - | /* EMPTY */ { } - opt_inline: | INLINE { Some(rhs parseState 1) } | /* EMPTY */ { None } diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 58e06721da2..0ca74e1ad6f 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -37,6 +37,11 @@ Případy sjednocení s malými písmeny jsou povolené jenom při použití atributu RequireQualifiedAccess. + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' symbol ..^ diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index b740ff53ade..5bb910c0b93 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -37,6 +37,11 @@ Diskriminierte Union-Fälle in Kleinbuchstaben sind nur zulässig, wenn das RequireQualifiedAccess-Attribut verwendet wird. + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' Symbol "..^" diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index 755995b0cbc..f930cc3130e 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -37,6 +37,11 @@ Los casos de unión discriminada en minúsculas solo se permiten cuando se usa el atributo RequireQualifiedAccess + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' símbolo "..^" diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index a73d049c106..ee90304b65d 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -37,6 +37,11 @@ Les cas d’union discriminée en minuscules sont uniquement autorisés lors de l’utilisation de l’attribut RequireQualifiedAccess. + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' symbole '..^' diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index 7568d912c32..d533fcf3383 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -37,6 +37,11 @@ I casi di unione discriminati minuscoli sono consentiti solo quando si usa l'attributo RequireQualifiedAccess + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' simbolo '..^' diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index c9642a7b238..3627feb9bf7 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -37,6 +37,11 @@ 小文字で区別される和集合のケースは、RequireQualifiedAccess 属性を使用する場合にのみ許可されます + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' シンボル '..^' diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index d02eb85f5b1..fdb8589dc36 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -37,6 +37,11 @@ 소문자로 구분된 공용 구조체 케이스는 RequireQualifiedAccess 특성을 사용하는 경우에만 허용됩니다. + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' 기호 '..^' diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index 30c77ac7915..612b025b4bc 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -37,6 +37,11 @@ Przypadki unii z dyskryminatorem z małymi literami są dozwolone tylko w przypadku używania atrybutu RequireQualifiedAccess + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' symbol „..^” diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 560a3bcc9f8..a4f48b46735 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -37,6 +37,11 @@ Os casos de união discriminados em letras minúsculas só são permitidos ao usar o atributo RequireQualifiedAccess + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' símbolo '..^' diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index 18e6978c0c7..1c8e749697d 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -37,6 +37,11 @@ Размеченные в нижнем регистре случаи объединения разрешены только при использовании атрибута RequireQualifiedAccess + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' символ "..^" diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index a56fa595c82..3a7631b488c 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -37,6 +37,11 @@ Küçük harf ayrımlı birleşim durumlarına yalnızca RequireQualifiedAccess özniteliği kullanılırken izin verilir + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' '..^' sembolü diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index cc62cbd1802..baec1f056fe 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -37,6 +37,11 @@ 仅当使用 RequireQualifiedAccess 属性时才允许区分小写的联合事例 + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' 符号 "..^" diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index 1cb335012c3..cd9bd4799a0 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -37,6 +37,11 @@ 只有在使用 RequireQualifiedAccess 屬性時,才允許小寫區分聯結案例 + + symbol '|' (directly before 'null') + symbol '|' (directly before 'null') + + symbol '..^' 符號 '..^' diff --git a/tests/AheadOfTime/Trimming/check.ps1 b/tests/AheadOfTime/Trimming/check.ps1 index 834c0b0aacc..bf5f29bc306 100644 --- a/tests/AheadOfTime/Trimming/check.ps1 +++ b/tests/AheadOfTime/Trimming/check.ps1 @@ -47,4 +47,4 @@ CheckTrim -root "SelfContained_Trimming_Test" -tfm "net472" -outputfile "FSharp. CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net472" -outputfile "StaticLinkedFSharpCore_Trimming_Test.exe" -expected_len -1 # Check net7.0 trimmed assemblies -CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net7.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 8821248 +CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net7.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 8822272 diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index b761ced68fd..5d902c1671a 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -94,6 +94,12 @@ + + + SyntaxTreeTestSource\%(RecursiveDir)\%(Extension)\%(Filename)%(Extension) + + + diff --git a/tests/fsharp/typecheck/sigs/neg04.bsl b/tests/fsharp/typecheck/sigs/neg04.bsl index 88ae776c8ca..f444d1f6ca9 100644 --- a/tests/fsharp/typecheck/sigs/neg04.bsl +++ b/tests/fsharp/typecheck/sigs/neg04.bsl @@ -30,10 +30,16 @@ neg04.fs(47,30,47,51): typecheck error FS0001: Type mismatch. Expecting a ''a seq -> 'n' but given a ''o list -> 'p' -The type ''a seq' does not match the type ''n list' +The type ''a list' does not match the type ''b seq' neg04.fs(47,49,47,51): typecheck error FS0784: This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope +neg04.fs(47,30,47,51): typecheck error FS0001: Type mismatch. Expecting a + ''a seq -> 'n' +but given a + ''o list -> 'p' +The type ''a list' does not match the type ''c seq' + neg04.fs(61,25,61,40): typecheck error FS0001: This expression was expected to have type 'ClassType1' but here has type diff --git a/tests/fsharp/typecheck/sigs/neg119b.bsl b/tests/fsharp/typecheck/sigs/neg119b.bsl index 259e2585998..414486b9017 100644 --- a/tests/fsharp/typecheck/sigs/neg119b.bsl +++ b/tests/fsharp/typecheck/sigs/neg119b.bsl @@ -6,7 +6,7 @@ Known return type: ((int -> int -> int) -> obj) Known type parameters: < obj , Applicatives.Ap > Available overloads: + - static member Applicatives.Ap.Return: 'a seq * Ap: Applicatives.Ap -> ('a -> 'a seq) // Argument at index 1 doesn't match - static member Applicatives.Ap.Return: ('r -> 'a) * Ap: Applicatives.Ap -> (('a -> 'r -> 'a2) -> 'a3 -> 'a -> 'r -> 'a2) // Argument at index 1 doesn't match - static member Applicatives.Ap.Return: System.Tuple<'a> * Ap: Applicatives.Ap -> ('a -> System.Tuple<'a>) // Argument at index 1 doesn't match - - static member Applicatives.Ap.Return: r: ^R * obj -> ('a1 -> ^R) when ^R: (static member Return: 'a1 -> ^R) // Argument 'r' doesn't match - - static member Applicatives.Ap.Return: seq<'a> * Ap: Applicatives.Ap -> ('a -> seq<'a>) // Argument at index 1 doesn't match Consider adding further type constraints + - static member Applicatives.Ap.Return: r: ^R * obj -> ('a1 -> ^R) when ^R: (static member Return: 'a1 -> ^R) // Argument 'r' doesn't match Consider adding further type constraints diff --git a/tests/fsharp/typecheck/sigs/neg29.bsl b/tests/fsharp/typecheck/sigs/neg29.bsl index dd2d49ffda1..5f75bb8cdb0 100644 --- a/tests/fsharp/typecheck/sigs/neg29.bsl +++ b/tests/fsharp/typecheck/sigs/neg29.bsl @@ -1,8 +1,8 @@ neg29.fs(5,19,6,16): parse error FS0010: Incomplete structured construct at or before this point in type name. Expected '>' or other token. -neg29.fs(9,1,9,1): parse error FS0010: Incomplete structured construct at or before this point in implementation file - neg29.fs(6,19,6,20): parse error FS0010: Unexpected symbol '(' in expression neg29.fs(6,18,6,19): parse error FS3156: Unexpected token '>' or incomplete expression + +neg29.fs(9,1,9,1): parse error FS0010: Incomplete structured construct at or before this point in implementation file diff --git a/tests/fsharp/typecheck/sigs/neg69.vsbsl b/tests/fsharp/typecheck/sigs/neg69.vsbsl index 1a0ddb7e009..45b72ad0d8f 100644 --- a/tests/fsharp/typecheck/sigs/neg69.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg69.vsbsl @@ -1,6 +1,3 @@ -neg69.fsx(87,6,87,12): typecheck error FS0912: This declaration element is not permitted in an augmentation - -neg69.fsx(87,6,87,12): typecheck error FS0929: This type requires a definition neg69.fsx(88,43,88,44): parse error FS1241: Expected type argument or static argument @@ -67,3 +64,7 @@ neg69.fsx(212,1,212,4): parse error FS0058: Possible incorrect indentation: this neg69.fsx(221,1,221,4): parse error FS0058: Possible incorrect indentation: this token is offside of context started at position (212:1). Try indenting this token further or using standard formatting conventions. neg69.fsx(242,1,242,3): parse error FS0058: Possible incorrect indentation: this token is offside of context started at position (221:1). Try indenting this token further or using standard formatting conventions. + +neg69.fsx(87,6,87,12): typecheck error FS0929: This type requires a definition + +neg69.fsx(87,6,87,12): typecheck error FS0912: This declaration element is not permitted in an augmentation diff --git a/tests/service/data/SyntaxTree/Nullness/AbstractClassProperty.fs b/tests/service/data/SyntaxTree/Nullness/AbstractClassProperty.fs new file mode 100644 index 00000000000..a11725eb01b --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/AbstractClassProperty.fs @@ -0,0 +1,3 @@ +[] +type AbstractBase() = + abstract Property1 : string | null with get, set diff --git a/tests/service/data/SyntaxTree/Nullness/AbstractClassProperty.fs.bsl b/tests/service/data/SyntaxTree/Nullness/AbstractClassProperty.fs.bsl new file mode 100644 index 00000000000..2bc15f69175 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/AbstractClassProperty.fs.bsl @@ -0,0 +1,60 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/AbstractClassProperty.fs", false, + QualifiedNameOfFile AbstractClassProperty, [], [], + [SynModuleOrNamespace + ([AbstractClassProperty], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([{ Attributes = + [{ TypeName = + SynLongIdent ([AbstractClass], [], [None]) + ArgExpr = Const (Unit, (1,2--1,15)) + Target = None + AppliesToGetterAndSetter = false + Range = (1,2--1,15) }] + Range = (1,0--1,17) }], None, [], [AbstractBase], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (2,5--2,17)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], SimplePats ([], [], (2,17--2,19)), None, + PreXmlDoc ((2,17), FSharp.Compiler.Xml.XmlDocCollector), + (2,5--2,17), { AsKeyword = None }); + AbstractSlot + (SynValSig + ([], SynIdent (Property1, None), + SynValTyparDecls (None, true), + WithNull + (LongIdent (SynLongIdent ([string], [], [None])), + false, (3,24--3,37)), + SynValInfo ([], SynArgInfo ([], false, None)), false, + false, + PreXmlDoc ((3,3), FSharp.Compiler.Xml.XmlDocCollector), + None, None, (3,3--3,51), + { LeadingKeyword = Abstract (3,3--3,11) + InlineKeyword = None + WithKeyword = Some (3,38--3,42) + EqualsRange = None }), + { IsInstance = true + IsDispatchSlot = true + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGetSet }, (3,3--3,51), + { GetSetKeywords = + Some (GetSet ((3,43--3,46), (3,48--3,51))) })], + (3,3--3,51)), [], + Some + (ImplicitCtor + (None, [], SimplePats ([], [], (2,17--2,19)), None, + PreXmlDoc ((2,17), FSharp.Compiler.Xml.XmlDocCollector), + (2,5--2,17), { AsKeyword = None })), (1,0--3,51), + { LeadingKeyword = Type (2,0--2,4) + EqualsRange = Some (2,20--2,21) + WithKeyword = None })], (1,0--3,51))], PreXmlDocEmpty, [], + None, (1,0--4,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/DuCaseStringOrNull.fs b/tests/service/data/SyntaxTree/Nullness/DuCaseStringOrNull.fs new file mode 100644 index 00000000000..6f1f90d780a --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/DuCaseStringOrNull.fs @@ -0,0 +1 @@ +type DU = MyCase of (string | null) diff --git a/tests/service/data/SyntaxTree/Nullness/DuCaseStringOrNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/DuCaseStringOrNull.fs.bsl new file mode 100644 index 00000000000..ba57735a1a8 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/DuCaseStringOrNull.fs.bsl @@ -0,0 +1,37 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/DuCaseStringOrNull.fs", false, + QualifiedNameOfFile DuCaseStringOrNull, [], [], + [SynModuleOrNamespace + ([DuCaseStringOrNull], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [DU], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,7)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (MyCase, None), + Fields + [SynField + ([], false, None, + Paren + (WithNull + (LongIdent + (SynLongIdent ([string], [], [None])), + false, (1,21--1,34)), (1,20--1,35)), + false, + PreXmlDoc ((1,20), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,20--1,35), { LeadingKeyword = None })], + PreXmlDoc ((1,10), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,10--1,35), { BarRange = None })], + (1,10--1,35)), (1,10--1,35)), [], None, (1,5--1,35), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,8--1,9) + WithKeyword = None })], (1,0--1,35))], PreXmlDocEmpty, [], + None, (1,0--2,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/DuCaseTuplePrecedence.fs b/tests/service/data/SyntaxTree/Nullness/DuCaseTuplePrecedence.fs new file mode 100644 index 00000000000..dda36337883 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/DuCaseTuplePrecedence.fs @@ -0,0 +1 @@ +type DU = MyCase of (string | null) * int diff --git a/tests/service/data/SyntaxTree/Nullness/DuCaseTuplePrecedence.fs.bsl b/tests/service/data/SyntaxTree/Nullness/DuCaseTuplePrecedence.fs.bsl new file mode 100644 index 00000000000..379722c41b2 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/DuCaseTuplePrecedence.fs.bsl @@ -0,0 +1,43 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/DuCaseTuplePrecedence.fs", false, + QualifiedNameOfFile DuCaseTuplePrecedence, [], [], + [SynModuleOrNamespace + ([DuCaseTuplePrecedence], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [DU], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,7)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (MyCase, None), + Fields + [SynField + ([], false, None, + Paren + (WithNull + (LongIdent + (SynLongIdent ([string], [], [None])), + false, (1,21--1,34)), (1,20--1,35)), + false, + PreXmlDoc ((1,20), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,20--1,35), { LeadingKeyword = None }); + SynField + ([], false, None, + LongIdent (SynLongIdent ([int], [], [None])), + false, + PreXmlDoc ((1,38), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,38--1,41), { LeadingKeyword = None })], + PreXmlDoc ((1,10), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,10--1,41), { BarRange = None })], + (1,10--1,41)), (1,10--1,41)), [], None, (1,5--1,41), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,8--1,9) + WithKeyword = None })], (1,0--1,41))], PreXmlDocEmpty, [], + None, (1,0--2,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/ExplicitField.fs b/tests/service/data/SyntaxTree/Nullness/ExplicitField.fs new file mode 100644 index 00000000000..fd93ac6b9f5 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/ExplicitField.fs @@ -0,0 +1,4 @@ +type MyStruct = + struct + val mutable myString : string | null + end diff --git a/tests/service/data/SyntaxTree/Nullness/ExplicitField.fs.bsl b/tests/service/data/SyntaxTree/Nullness/ExplicitField.fs.bsl new file mode 100644 index 00000000000..b06e92d77eb --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/ExplicitField.fs.bsl @@ -0,0 +1,30 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/ExplicitField.fs", false, + QualifiedNameOfFile ExplicitField, [], [], + [SynModuleOrNamespace + ([ExplicitField], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [MyStruct], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,13)), + ObjectModel + (Struct, + [ValField + (SynField + ([], false, Some myString, + WithNull + (LongIdent (SynLongIdent ([string], [], [None])), + false, (3,31--3,44)), true, + PreXmlDoc ((3,8), FSharp.Compiler.Xml.XmlDocCollector), + None, (3,20--3,44), + { LeadingKeyword = Some (Val (3,8--3,11)) }), + (3,8--3,44))], (2,4--4,7)), [], None, (1,5--4,7), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,14--1,15) + WithKeyword = None })], (1,0--4,7))], PreXmlDocEmpty, [], + None, (1,0--5,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/FunctionArgAsPatternWithNullCase.fs b/tests/service/data/SyntaxTree/Nullness/FunctionArgAsPatternWithNullCase.fs new file mode 100644 index 00000000000..5cb343224f6 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/FunctionArgAsPatternWithNullCase.fs @@ -0,0 +1 @@ +let myFunc ("abc" | "" : string | null | "123") = 15 diff --git a/tests/service/data/SyntaxTree/Nullness/FunctionArgAsPatternWithNullCase.fs.bsl b/tests/service/data/SyntaxTree/Nullness/FunctionArgAsPatternWithNullCase.fs.bsl new file mode 100644 index 00000000000..5a519d0f7e5 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/FunctionArgAsPatternWithNullCase.fs.bsl @@ -0,0 +1,46 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/FunctionArgAsPatternWithNullCase.fs", false, + QualifiedNameOfFile FunctionArgAsPatternWithNullCase, [], [], + [SynModuleOrNamespace + ([FunctionArgAsPatternWithNullCase], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), None, None), + LongIdent + (SynLongIdent ([myFunc], [], [None]), None, None, + Pats + [Paren + (Or + (Or + (Const + (String ("abc", Regular, (1,12--1,17)), + (1,12--1,17)), + Typed + (Const + (String ("", Regular, (1,20--1,22)), + (1,20--1,22)), + WithNull + (LongIdent + (SynLongIdent ([string], [], [None])), + false, (1,25--1,38)), (1,20--1,38)), + (1,12--1,38), { BarRange = (1,18--1,19) }), + Const + (String ("123", Regular, (1,41--1,46)), + (1,41--1,46)), (1,12--1,46), + { BarRange = (1,39--1,40) }), (1,11--1,47))], None, + (1,4--1,47)), None, Const (Int32 15, (1,50--1,52)), + (1,4--1,47), NoneAtLet, { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,48--1,49) })], + (1,0--1,52))], PreXmlDocEmpty, [], None, (1,0--2,0), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/GenericFunctionReturnTypeNotStructNull.fs b/tests/service/data/SyntaxTree/Nullness/GenericFunctionReturnTypeNotStructNull.fs new file mode 100644 index 00000000000..ea4694fc5e8 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericFunctionReturnTypeNotStructNull.fs @@ -0,0 +1 @@ +let myFunc() : 'T when 'T : not struct and 'T:null = null diff --git a/tests/service/data/SyntaxTree/Nullness/GenericFunctionReturnTypeNotStructNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/GenericFunctionReturnTypeNotStructNull.fs.bsl new file mode 100644 index 00000000000..a3a42b1fb1f --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericFunctionReturnTypeNotStructNull.fs.bsl @@ -0,0 +1,43 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/GenericFunctionReturnTypeNotStructNull.fs", false, + QualifiedNameOfFile GenericFunctionReturnTypeNotStructNull, [], [], + [SynModuleOrNamespace + ([GenericFunctionReturnTypeNotStructNull], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([[]], SynArgInfo ([], false, None)), None, + None), + LongIdent + (SynLongIdent ([myFunc], [], [None]), None, None, + Pats [Paren (Const (Unit, (1,10--1,12)), (1,10--1,12))], + None, (1,4--1,12)), + Some + (SynBindingReturnInfo + (WithGlobalConstraints + (Var (SynTypar (T, None, false), (1,15--1,17)), + [WhereTyparIsReferenceType + (SynTypar (T, None, false), (1,23--1,38)); + WhereTyparSupportsNull + (SynTypar (T, None, false), (1,43--1,50))], + (1,15--1,50)), (1,15--1,50), [], + { ColonRange = Some (1,13--1,14) })), + Typed + (Null (1,53--1,57), + WithGlobalConstraints + (Var (SynTypar (T, None, false), (1,15--1,17)), + [WhereTyparIsReferenceType + (SynTypar (T, None, false), (1,23--1,38)); + WhereTyparSupportsNull + (SynTypar (T, None, false), (1,43--1,50))], + (1,15--1,50)), (1,53--1,57)), (1,4--1,12), NoneAtLet, + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,51--1,52) })], (1,0--1,57))], + PreXmlDocEmpty, [], None, (1,0--2,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNotNull.fs b/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNotNull.fs new file mode 100644 index 00000000000..9f80e8f8ac2 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNotNull.fs @@ -0,0 +1 @@ +let myFunc (x: 'T when 'T: not null) = 42 diff --git a/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNotNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNotNull.fs.bsl new file mode 100644 index 00000000000..e648c231c86 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNotNull.fs.bsl @@ -0,0 +1,36 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/GenericFunctionTyparNotNull.fs", false, + QualifiedNameOfFile GenericFunctionTyparNotNull, [], [], + [SynModuleOrNamespace + ([GenericFunctionTyparNotNull], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None, None), + LongIdent + (SynLongIdent ([myFunc], [], [None]), None, None, + Pats + [Paren + (Typed + (Named + (SynIdent (x, None), false, None, (1,12--1,13)), + WithGlobalConstraints + (Var (SynTypar (T, None, false), (1,15--1,17)), + [WhereTyparNotSupportsNull + (SynTypar (T, None, false), (1,23--1,35))], + (1,15--1,35)), (1,12--1,35)), (1,11--1,36))], + None, (1,4--1,36)), None, Const (Int32 42, (1,39--1,41)), + (1,4--1,36), NoneAtLet, { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,37--1,38) })], + (1,0--1,41))], PreXmlDocEmpty, [], None, (1,0--2,0), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNull.fs b/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNull.fs new file mode 100644 index 00000000000..712e2b94c49 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNull.fs @@ -0,0 +1 @@ +let myFunc (x: 'T when 'T: null) = 42 diff --git a/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNull.fs.bsl new file mode 100644 index 00000000000..cf50c657f30 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericFunctionTyparNull.fs.bsl @@ -0,0 +1,36 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/GenericFunctionTyparNull.fs", false, + QualifiedNameOfFile GenericFunctionTyparNull, [], [], + [SynModuleOrNamespace + ([GenericFunctionTyparNull], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None, None), + LongIdent + (SynLongIdent ([myFunc], [], [None]), None, None, + Pats + [Paren + (Typed + (Named + (SynIdent (x, None), false, None, (1,12--1,13)), + WithGlobalConstraints + (Var (SynTypar (T, None, false), (1,15--1,17)), + [WhereTyparSupportsNull + (SynTypar (T, None, false), (1,23--1,31))], + (1,15--1,31)), (1,12--1,31)), (1,11--1,32))], + None, (1,4--1,32)), None, Const (Int32 42, (1,35--1,37)), + (1,4--1,32), NoneAtLet, { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,33--1,34) })], + (1,0--1,37))], PreXmlDocEmpty, [], None, (1,0--2,0), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNull.fs b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNull.fs new file mode 100644 index 00000000000..220b9e370b9 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNull.fs @@ -0,0 +1 @@ +type C<'T when 'T: not null> = class end diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNull.fs.bsl new file mode 100644 index 00000000000..e874ec38674 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNull.fs.bsl @@ -0,0 +1,27 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/GenericTypeNotNull.fs", false, + QualifiedNameOfFile GenericTypeNotNull, [], [], + [SynModuleOrNamespace + ([GenericTypeNotNull], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] })], + [WhereTyparNotSupportsNull + (SynTypar (T, None, false), (1,15--1,27))], + (1,6--1,28))), [], [C], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (1,5--1,6)), + ObjectModel (Class, [], (1,31--1,40)), [], None, (1,5--1,40), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,29--1,30) + WithKeyword = None })], (1,0--1,40))], PreXmlDocEmpty, [], + None, (1,0--2,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNullAndOtherConstraint.fs b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNullAndOtherConstraint.fs new file mode 100644 index 00000000000..71d3333c057 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNullAndOtherConstraint.fs @@ -0,0 +1 @@ +type C<'T when 'T: not null and 'T:equality> = class end diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNullAndOtherConstraint.fs.bsl b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNullAndOtherConstraint.fs.bsl new file mode 100644 index 00000000000..7a53c3be066 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotNullAndOtherConstraint.fs.bsl @@ -0,0 +1,29 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/GenericTypeNotNullAndOtherConstraint.fs", false, + QualifiedNameOfFile GenericTypeNotNullAndOtherConstraint, [], [], + [SynModuleOrNamespace + ([GenericTypeNotNullAndOtherConstraint], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] })], + [WhereTyparNotSupportsNull + (SynTypar (T, None, false), (1,15--1,27)); + WhereTyparIsEquatable + (SynTypar (T, None, false), (1,32--1,43))], + (1,6--1,44))), [], [C], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (1,5--1,6)), + ObjectModel (Class, [], (1,47--1,56)), [], None, (1,5--1,56), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,45--1,46) + WithKeyword = None })], (1,0--1,56))], PreXmlDocEmpty, [], + None, (1,0--2,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane.fs b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane.fs new file mode 100644 index 00000000000..8b3b5793b92 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane.fs @@ -0,0 +1 @@ +type C<'T when 'T: not struct and 'T:equality> = class end diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane.fs.bsl b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane.fs.bsl new file mode 100644 index 00000000000..6ebe197154b --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane.fs.bsl @@ -0,0 +1,34 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane.fs", + false, + QualifiedNameOfFile GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane, + [], [], + [SynModuleOrNamespace + ([GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane], false, + AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] })], + [WhereTyparIsReferenceType + (SynTypar (T, None, false), (1,15--1,29)); + WhereTyparIsEquatable + (SynTypar (T, None, false), (1,34--1,45))], + (1,6--1,46))), [], [C], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (1,5--1,6)), + ObjectModel (Class, [], (1,49--1,58)), [], None, (1,5--1,58), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,47--1,48) + WithKeyword = None })], (1,0--1,58))], PreXmlDocEmpty, [], + None, (1,0--2,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane' based on the file name 'GenericTypeNotStructAndOtherConstraint-I_am_Still_Sane.fs'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file. diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeNull.fs b/tests/service/data/SyntaxTree/Nullness/GenericTypeNull.fs new file mode 100644 index 00000000000..67b7b23c154 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeNull.fs @@ -0,0 +1 @@ +type C<'T when 'T: null> = class end diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/GenericTypeNull.fs.bsl new file mode 100644 index 00000000000..184b29d69d3 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeNull.fs.bsl @@ -0,0 +1,27 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/GenericTypeNull.fs", false, + QualifiedNameOfFile GenericTypeNull, [], [], + [SynModuleOrNamespace + ([GenericTypeNull], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] })], + [WhereTyparSupportsNull + (SynTypar (T, None, false), (1,15--1,23))], + (1,6--1,24))), [], [C], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (1,5--1,6)), + ObjectModel (Class, [], (1,27--1,36)), [], None, (1,5--1,36), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,25--1,26) + WithKeyword = None })], (1,0--1,36))], PreXmlDocEmpty, [], + None, (1,0--2,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeOtherConstraintAndThenNotNull.fs b/tests/service/data/SyntaxTree/Nullness/GenericTypeOtherConstraintAndThenNotNull.fs new file mode 100644 index 00000000000..634161d9288 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeOtherConstraintAndThenNotNull.fs @@ -0,0 +1 @@ +type C<'T when 'T:equality and 'T: not null> = class end diff --git a/tests/service/data/SyntaxTree/Nullness/GenericTypeOtherConstraintAndThenNotNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/GenericTypeOtherConstraintAndThenNotNull.fs.bsl new file mode 100644 index 00000000000..14ce1cec8b7 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/GenericTypeOtherConstraintAndThenNotNull.fs.bsl @@ -0,0 +1,29 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/GenericTypeOtherConstraintAndThenNotNull.fs", false, + QualifiedNameOfFile GenericTypeOtherConstraintAndThenNotNull, [], [], + [SynModuleOrNamespace + ([GenericTypeOtherConstraintAndThenNotNull], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] })], + [WhereTyparIsEquatable + (SynTypar (T, None, false), (1,15--1,26)); + WhereTyparNotSupportsNull + (SynTypar (T, None, false), (1,31--1,43))], + (1,6--1,44))), [], [C], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (1,5--1,6)), + ObjectModel (Class, [], (1,47--1,56)), [], None, (1,5--1,56), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,45--1,46) + WithKeyword = None })], (1,0--1,56))], PreXmlDocEmpty, [], + None, (1,0--2,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/IntListOrNull.fs b/tests/service/data/SyntaxTree/Nullness/IntListOrNull.fs new file mode 100644 index 00000000000..2f3dff3b4c8 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/IntListOrNull.fs @@ -0,0 +1 @@ +let x : int list | null = [] diff --git a/tests/service/data/SyntaxTree/Nullness/IntListOrNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/IntListOrNull.fs.bsl new file mode 100644 index 00000000000..3e18b8f3910 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/IntListOrNull.fs.bsl @@ -0,0 +1,37 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/IntListOrNull.fs", false, + QualifiedNameOfFile IntListOrNull, [], [], + [SynModuleOrNamespace + ([IntListOrNull], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None, + None), Named (SynIdent (x, None), false, None, (1,4--1,5)), + Some + (SynBindingReturnInfo + (WithNull + (App + (LongIdent (SynLongIdent ([list], [], [None])), + None, + [LongIdent (SynLongIdent ([int], [], [None]))], [], + None, true, (1,8--1,16)), false, (1,8--1,23)), + (1,8--1,23), [], { ColonRange = Some (1,6--1,7) })), + Typed + (ArrayOrList (false, [], (1,26--1,28)), + WithNull + (App + (LongIdent (SynLongIdent ([list], [], [None])), None, + [LongIdent (SynLongIdent ([int], [], [None]))], [], + None, true, (1,8--1,16)), false, (1,8--1,23)), + (1,26--1,28)), (1,4--1,5), Yes (1,0--1,28), + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,24--1,25) })], (1,0--1,28))], + PreXmlDocEmpty, [], None, (1,0--2,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/IntListOrNullOrNullOrNull.fs b/tests/service/data/SyntaxTree/Nullness/IntListOrNullOrNullOrNull.fs new file mode 100644 index 00000000000..f162f811711 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/IntListOrNullOrNullOrNull.fs @@ -0,0 +1 @@ +let x : int list | null | null | null = [] diff --git a/tests/service/data/SyntaxTree/Nullness/IntListOrNullOrNullOrNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/IntListOrNullOrNullOrNull.fs.bsl new file mode 100644 index 00000000000..01b86c58866 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/IntListOrNullOrNullOrNull.fs.bsl @@ -0,0 +1,39 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/IntListOrNullOrNullOrNull.fs", false, + QualifiedNameOfFile IntListOrNullOrNullOrNull, [], [], + [SynModuleOrNamespace + ([IntListOrNullOrNullOrNull], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None, + None), Named (SynIdent (x, None), false, None, (1,4--1,5)), + Some + (SynBindingReturnInfo + (WithNull + (App + (LongIdent (SynLongIdent ([list], [], [None])), + None, + [LongIdent (SynLongIdent ([int], [], [None]))], [], + None, true, (1,8--1,16)), false, (1,8--1,23)), + (1,8--1,23), [], { ColonRange = Some (1,6--1,7) })), + Typed + (ArbitraryAfterError ("localBinding2", (1,23--1,23)), + WithNull + (App + (LongIdent (SynLongIdent ([list], [], [None])), None, + [LongIdent (SynLongIdent ([int], [], [None]))], [], + None, true, (1,8--1,16)), false, (1,8--1,23)), + (1,23--1,23)), (1,4--1,5), Yes (1,0--1,23), + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = None })], (1,0--1,23))], PreXmlDocEmpty, [], + None, (1,0--2,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,24)-(1,25) parse error Unexpected symbol '|' (directly before 'null') in binding. Expected '=' or other token. diff --git a/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCast.fs b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCast.fs new file mode 100644 index 00000000000..9986cca84a6 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCast.fs @@ -0,0 +1,2 @@ +match x with +| :? string | null -> () diff --git a/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCast.fs.bsl b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCast.fs.bsl new file mode 100644 index 00000000000..86094715714 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCast.fs.bsl @@ -0,0 +1,23 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/MatchWithTypeCast.fs", false, + QualifiedNameOfFile MatchWithTypeCast, [], [], + [SynModuleOrNamespace + ([MatchWithTypeCast], false, AnonModule, + [Expr + (Match + (Yes (1,0--1,12), Ident x, + [SynMatchClause + (Or + (IsInst + (LongIdent (SynLongIdent ([string], [], [None])), + (2,2--2,11)), Null (2,14--2,18), (2,2--2,18), + { BarRange = (2,12--2,13) }), None, + Const (Unit, (2,22--2,24)), (2,2--2,24), Yes, + { ArrowRange = Some (2,19--2,21) + BarRange = Some (2,0--2,1) })], (1,0--2,24), + { MatchKeyword = (1,0--1,5) + WithKeyword = (1,8--1,12) }), (1,0--2,24))], PreXmlDocEmpty, + [], None, (1,0--3,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParens.fs b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParens.fs new file mode 100644 index 00000000000..180b3db96df --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParens.fs @@ -0,0 +1,2 @@ +match x with +| :? (string | null) -> () diff --git a/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParens.fs.bsl b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParens.fs.bsl new file mode 100644 index 00000000000..e3a174fcf11 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParens.fs.bsl @@ -0,0 +1,23 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/MatchWithTypeCastParens.fs", false, + QualifiedNameOfFile MatchWithTypeCastParens, [], [], + [SynModuleOrNamespace + ([MatchWithTypeCastParens], false, AnonModule, + [Expr + (Match + (Yes (1,0--1,12), Ident x, + [SynMatchClause + (IsInst + (Paren + (WithNull + (LongIdent (SynLongIdent ([string], [], [None])), + false, (2,6--2,19)), (2,5--2,20)), (2,2--2,20)), + None, Const (Unit, (2,24--2,26)), (2,2--2,26), Yes, + { ArrowRange = Some (2,21--2,23) + BarRange = Some (2,0--2,1) })], (1,0--2,26), + { MatchKeyword = (1,0--1,5) + WithKeyword = (1,8--1,12) }), (1,0--2,26))], PreXmlDocEmpty, + [], None, (1,0--3,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParensAndSeparateNullCase.fs b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParensAndSeparateNullCase.fs new file mode 100644 index 00000000000..c738f9f8fed --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParensAndSeparateNullCase.fs @@ -0,0 +1,2 @@ +match x with +| :? (string | null) | null -> () diff --git a/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParensAndSeparateNullCase.fs.bsl b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParensAndSeparateNullCase.fs.bsl new file mode 100644 index 00000000000..2c62cd5cd41 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/MatchWithTypeCastParensAndSeparateNullCase.fs.bsl @@ -0,0 +1,26 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/MatchWithTypeCastParensAndSeparateNullCase.fs", false, + QualifiedNameOfFile MatchWithTypeCastParensAndSeparateNullCase, [], [], + [SynModuleOrNamespace + ([MatchWithTypeCastParensAndSeparateNullCase], false, AnonModule, + [Expr + (Match + (Yes (1,0--1,12), Ident x, + [SynMatchClause + (Or + (IsInst + (Paren + (WithNull + (LongIdent (SynLongIdent ([string], [], [None])), + false, (2,6--2,19)), (2,5--2,20)), (2,2--2,20)), + Null (2,23--2,27), (2,2--2,27), + { BarRange = (2,21--2,22) }), None, + Const (Unit, (2,31--2,33)), (2,2--2,33), Yes, + { ArrowRange = Some (2,28--2,30) + BarRange = Some (2,0--2,1) })], (1,0--2,33), + { MatchKeyword = (1,0--1,5) + WithKeyword = (1,8--1,12) }), (1,0--2,33))], PreXmlDocEmpty, + [], None, (1,0--3,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/NullAnnotatedExpression.fs b/tests/service/data/SyntaxTree/Nullness/NullAnnotatedExpression.fs new file mode 100644 index 00000000000..b824f784a61 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/NullAnnotatedExpression.fs @@ -0,0 +1 @@ +let x : Expression | null> | null = null diff --git a/tests/service/data/SyntaxTree/Nullness/NullAnnotatedExpression.fs.bsl b/tests/service/data/SyntaxTree/Nullness/NullAnnotatedExpression.fs.bsl new file mode 100644 index 00000000000..c29a384e013 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/NullAnnotatedExpression.fs.bsl @@ -0,0 +1,68 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/NullAnnotatedExpression.fs", false, + QualifiedNameOfFile NullAnnotatedExpression, [], [], + [SynModuleOrNamespace + ([NullAnnotatedExpression], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None, + None), Named (SynIdent (x, None), false, None, (1,4--1,5)), + Some + (SynBindingReturnInfo + (WithNull + (App + (LongIdent + (SynLongIdent ([Expression], [], [None])), + Some (1,18--1,19), + [WithNull + (App + (LongIdent + (SynLongIdent ([Func], [], [None])), + Some (1,23--1,24), + [WithNull + (LongIdent + (SynLongIdent ([string], [], [None])), + false, (1,24--1,37)); + WithNull + (LongIdent + (SynLongIdent ([T], [], [None])), + false, (1,39--1,47))], [(1,37--1,38)], + Some (1,47--1,48), false, (1,19--1,48)), + false, (1,19--1,55))], [], Some (1,55--1,56), + false, (1,8--1,56)), false, (1,8--1,63)), + (1,8--1,63), [], { ColonRange = Some (1,6--1,7) })), + Typed + (Null (1,66--1,70), + WithNull + (App + (LongIdent (SynLongIdent ([Expression], [], [None])), + Some (1,18--1,19), + [WithNull + (App + (LongIdent (SynLongIdent ([Func], [], [None])), + Some (1,23--1,24), + [WithNull + (LongIdent + (SynLongIdent ([string], [], [None])), + false, (1,24--1,37)); + WithNull + (LongIdent (SynLongIdent ([T], [], [None])), + false, (1,39--1,47))], [(1,37--1,38)], + Some (1,47--1,48), false, (1,19--1,48)), false, + (1,19--1,55))], [], Some (1,55--1,56), false, + (1,8--1,56)), false, (1,8--1,63)), (1,66--1,70)), + (1,4--1,5), Yes (1,0--1,70), + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,64--1,65) })], (1,0--1,70))], + PreXmlDocEmpty, [], None, (1,0--2,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(1,23)-(1,48) parse warning Remove spaces between the type name and type parameter, e.g. "C<'T>", not "C <'T>". Type parameters must be placed directly adjacent to the type name. +(1,18)-(1,56) parse warning Remove spaces between the type name and type parameter, e.g. "C<'T>", not "C <'T>". Type parameters must be placed directly adjacent to the type name. diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionAnnotatedInlinePatternMatch.fs b/tests/service/data/SyntaxTree/Nullness/RegressionAnnotatedInlinePatternMatch.fs new file mode 100644 index 00000000000..e608c5198c9 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionAnnotatedInlinePatternMatch.fs @@ -0,0 +1,2 @@ +match x with +| "123" -> "": string | null -> "456" \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionAnnotatedInlinePatternMatch.fs.bsl b/tests/service/data/SyntaxTree/Nullness/RegressionAnnotatedInlinePatternMatch.fs.bsl new file mode 100644 index 00000000000..54e114c95ab --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionAnnotatedInlinePatternMatch.fs.bsl @@ -0,0 +1,29 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/RegressionAnnotatedInlinePatternMatch.fs", false, + QualifiedNameOfFile RegressionAnnotatedInlinePatternMatch, [], [], + [SynModuleOrNamespace + ([RegressionAnnotatedInlinePatternMatch], false, AnonModule, + [Expr + (Match + (Yes (1,0--1,12), Ident x, + [SynMatchClause + (Const (String ("123", Regular, (2,2--2,7)), (2,2--2,7)), + None, + Typed + (Const (String ("", Regular, (2,11--2,13)), (2,11--2,13)), + Fun + (WithNull + (LongIdent (SynLongIdent ([string], [], [None])), + false, (2,15--2,28)), + StaticConstant + (String ("456", Regular, (2,32--2,37)), + (2,32--2,37)), (2,15--2,37), + { ArrowRange = (2,29--2,31) }), (2,11--2,37)), + (2,2--2,37), Yes, { ArrowRange = Some (2,8--2,10) + BarRange = Some (2,0--2,1) })], + (1,0--2,37), { MatchKeyword = (1,0--1,5) + WithKeyword = (1,8--1,12) }), (1,0--2,37))], + PreXmlDocEmpty, [], None, (1,0--2,37), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionChoiceType.fs b/tests/service/data/SyntaxTree/Nullness/RegressionChoiceType.fs new file mode 100644 index 00000000000..dde76747ac4 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionChoiceType.fs @@ -0,0 +1,7 @@ +type MyChoice<'T1,'T2> = + + /// Choice 1 of 2 choices + | MyChoice of 'T1 + + /// Choice 2 of 2 choices + | MyChoice of 'T2 diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionChoiceType.fs.bsl b/tests/service/data/SyntaxTree/Nullness/RegressionChoiceType.fs.bsl new file mode 100644 index 00000000000..3ec9bd46d66 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionChoiceType.fs.bsl @@ -0,0 +1,53 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/RegressionChoiceType.fs", false, + QualifiedNameOfFile RegressionChoiceType, [], [], + [SynModuleOrNamespace + ([RegressionChoiceType], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (T1, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (T2, None, false), [], + { AmpersandRanges = [] })], [], (1,13--1,22))), + [], [MyChoice], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (1,5--1,13)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (MyChoice, None), + Fields + [SynField + ([], false, None, + Var (SynTypar (T1, None, false), (4,16--4,19)), + false, + PreXmlDoc ((4,16), FSharp.Compiler.Xml.XmlDocCollector), + None, (4,16--4,19), { LeadingKeyword = None })], + PreXmlDoc ((4,2), FSharp.Compiler.Xml.XmlDocCollector), + None, (3,2--4,19), { BarRange = Some (4,2--4,3) }); + SynUnionCase + ([], SynIdent (MyChoice, None), + Fields + [SynField + ([], false, None, + Var (SynTypar (T2, None, false), (7,16--7,19)), + false, + PreXmlDoc ((7,16), FSharp.Compiler.Xml.XmlDocCollector), + None, (7,16--7,19), { LeadingKeyword = None })], + PreXmlDoc ((7,2), FSharp.Compiler.Xml.XmlDocCollector), + None, (6,2--7,19), { BarRange = Some (7,2--7,3) })], + (3,2--7,19)), (3,2--7,19)), [], None, (1,5--7,19), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,23--1,24) + WithKeyword = None })], (1,0--7,19))], PreXmlDocEmpty, [], + None, (1,0--8,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionListType.fs b/tests/service/data/SyntaxTree/Nullness/RegressionListType.fs new file mode 100644 index 00000000000..fca67d8f23e --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionListType.fs @@ -0,0 +1,3 @@ +type List<'T> = + | ([]) + | ( :: ) of Head: 'T * Tail: 'T list \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionListType.fs.bsl b/tests/service/data/SyntaxTree/Nullness/RegressionListType.fs.bsl new file mode 100644 index 00000000000..481bbb378bc --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionListType.fs.bsl @@ -0,0 +1,63 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/RegressionListType.fs", false, + QualifiedNameOfFile RegressionListType, [], [], + [SynModuleOrNamespace + ([RegressionListType], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] })], [], (1,9--1,13))), [], + [List], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (1,5--1,9)), + Simple + (Union + (None, + [SynUnionCase + ([], + SynIdent + (op_Nil, + Some + (OriginalNotationWithParen + ((2,6--2,7), "[]", (2,8--2,9)))), Fields [], + PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (2,6--2,10), { BarRange = Some (2,4--2,5) }); + SynUnionCase + ([], + SynIdent + (op_ColonColon, + Some + (OriginalNotationWithParen + ((3,6--3,7), "::", (3,11--3,12)))), + Fields + [SynField + ([], false, Some Head, + Var (SynTypar (T, None, false), (3,23--3,25)), + false, + PreXmlDoc ((3,17), FSharp.Compiler.Xml.XmlDocCollector), + None, (3,17--3,25), { LeadingKeyword = None }); + SynField + ([], false, Some Tail, + App + (LongIdent + (SynLongIdent ([list], [], [None])), None, + [Var + (SynTypar (T, None, false), (3,34--3,36))], + [], None, true, (3,34--3,41)), false, + PreXmlDoc ((3,28), FSharp.Compiler.Xml.XmlDocCollector), + None, (3,28--3,41), { LeadingKeyword = None })], + PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (3,6--3,41), { BarRange = Some (3,4--3,5) })], + (2,4--3,41)), (2,4--3,41)), [], None, (1,5--3,41), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,14--1,15) + WithKeyword = None })], (1,0--3,41))], PreXmlDocEmpty, [], + None, (1,0--3,41), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionOneLinerOptionType.fs b/tests/service/data/SyntaxTree/Nullness/RegressionOneLinerOptionType.fs new file mode 100644 index 00000000000..4b54405dff0 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionOneLinerOptionType.fs @@ -0,0 +1 @@ +type MyFlatOption = None | Some of string \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionOneLinerOptionType.fs.bsl b/tests/service/data/SyntaxTree/Nullness/RegressionOneLinerOptionType.fs.bsl new file mode 100644 index 00000000000..5b785c961d5 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionOneLinerOptionType.fs.bsl @@ -0,0 +1,37 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/RegressionOneLinerOptionType.fs", false, + QualifiedNameOfFile RegressionOneLinerOptionType, [], [], + [SynModuleOrNamespace + ([RegressionOneLinerOptionType], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [MyFlatOption], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,17)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (None, None), Fields [], + PreXmlDoc ((1,20), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,20--1,24), { BarRange = None }); + SynUnionCase + ([], SynIdent (Some, None), + Fields + [SynField + ([], false, None, + LongIdent + (SynLongIdent ([string], [], [None])), false, + PreXmlDoc ((1,35), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,35--1,41), { LeadingKeyword = None })], + PreXmlDoc ((1,25), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,27--1,41), { BarRange = Some (1,25--1,26) })], + (1,20--1,41)), (1,20--1,41)), [], None, (1,5--1,41), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,18--1,19) + WithKeyword = None })], (1,0--1,41))], PreXmlDocEmpty, [], + None, (1,0--1,41), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionOptionType.fs b/tests/service/data/SyntaxTree/Nullness/RegressionOptionType.fs new file mode 100644 index 00000000000..8b1018d513f --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionOptionType.fs @@ -0,0 +1,3 @@ +type Option<'T> = + | None: 'T option + | Some: Value:'T -> 'T option \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionOptionType.fs.bsl b/tests/service/data/SyntaxTree/Nullness/RegressionOptionType.fs.bsl new file mode 100644 index 00000000000..5491684ccaa --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionOptionType.fs.bsl @@ -0,0 +1,64 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/RegressionOptionType.fs", false, + QualifiedNameOfFile RegressionOptionType, [], [], + [SynModuleOrNamespace + ([RegressionOptionType], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] })], [], (1,11--1,15))), + [], [Option], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (1,5--1,11)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (None, None), + FullType + (App + (LongIdent + (SynLongIdent ([option], [], [None])), None, + [Var (SynTypar (T, None, false), (2,18--2,20))], + [], None, true, (2,18--2,27)), + SynValInfo ([], SynArgInfo ([], false, None))), + PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (2,6--2,27), { BarRange = Some (2,4--2,5) }); + SynUnionCase + ([], SynIdent (Some, None), + FullType + (Fun + (SignatureParameter + ([], false, Some Value, + Var + (SynTypar (T, None, false), (3,18--3,20)), + (3,12--3,20)), + App + (LongIdent + (SynLongIdent ([option], [], [None])), + None, + [Var + (SynTypar (T, None, false), (3,24--3,26))], + [], None, true, (3,24--3,33)), (3,12--3,33), + { ArrowRange = (3,21--3,23) }), + SynValInfo + ([[SynArgInfo ([], false, Some Value)]], + SynArgInfo ([], false, None))), + PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (3,6--3,33), { BarRange = Some (3,4--3,5) })], + (2,4--3,33)), (2,4--3,33)), [], None, (1,5--3,33), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,16--1,17) + WithKeyword = None })], (1,0--3,33))], PreXmlDocEmpty, [], + None, (1,0--3,34), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(2,6)-(2,27) parse warning This construct is deprecated: it is only for use in the F# library +(3,6)-(3,33) parse warning This construct is deprecated: it is only for use in the F# library diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionOrPattern.fs b/tests/service/data/SyntaxTree/Nullness/RegressionOrPattern.fs new file mode 100644 index 00000000000..d8374a93f90 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionOrPattern.fs @@ -0,0 +1,3 @@ +match exn with +| InternalError (s, _) +| Failure s as exn -> () \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionOrPattern.fs.bsl b/tests/service/data/SyntaxTree/Nullness/RegressionOrPattern.fs.bsl new file mode 100644 index 00000000000..82fe5cb33d5 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionOrPattern.fs.bsl @@ -0,0 +1,40 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/RegressionOrPattern.fs", false, + QualifiedNameOfFile RegressionOrPattern, [], [], + [SynModuleOrNamespace + ([RegressionOrPattern], false, AnonModule, + [Expr + (Match + (Yes (1,0--1,14), Ident exn, + [SynMatchClause + (As + (Or + (LongIdent + (SynLongIdent ([InternalError], [], [None]), None, + None, + Pats + [Paren + (Tuple + (false, + [Named + (SynIdent (s, None), false, None, + (2,17--2,18)); Wild (2,20--2,21)], + [(2,18--2,19)], (2,17--2,21)), + (2,16--2,22))], None, (2,2--2,22)), + LongIdent + (SynLongIdent ([Failure], [], [None]), None, None, + Pats + [Named + (SynIdent (s, None), false, None, + (3,10--3,11))], None, (3,2--3,11)), + (2,2--3,11), { BarRange = (3,0--3,1) }), + Named (SynIdent (exn, None), false, None, (3,15--3,18)), + (2,2--3,18)), None, Const (Unit, (3,22--3,24)), + (2,2--3,24), Yes, { ArrowRange = Some (3,19--3,21) + BarRange = Some (2,0--2,1) })], + (1,0--3,24), { MatchKeyword = (1,0--1,5) + WithKeyword = (1,10--1,14) }), (1,0--3,24))], + PreXmlDocEmpty, [], None, (1,0--3,24), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionResultType.fs b/tests/service/data/SyntaxTree/Nullness/RegressionResultType.fs new file mode 100644 index 00000000000..b2974154002 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionResultType.fs @@ -0,0 +1,7 @@ + type MyResult<'T,'TError> = + + /// Represents an OK or a Successful result. The code succeeded with a value of 'T. + | Ok of ResultValue:'T + + /// Represents an Error or a Failure. The code failed with a value of 'TError representing what went wrong. + | Error of ErrorValue:'TError \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Nullness/RegressionResultType.fs.bsl b/tests/service/data/SyntaxTree/Nullness/RegressionResultType.fs.bsl new file mode 100644 index 00000000000..fea7c9a9a59 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/RegressionResultType.fs.bsl @@ -0,0 +1,54 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/RegressionResultType.fs", false, + QualifiedNameOfFile RegressionResultType, [], [], + [SynModuleOrNamespace + ([RegressionResultType], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], + Some + (PostfixList + ([SynTyparDecl + ([], SynTypar (T, None, false), [], + { AmpersandRanges = [] }); + SynTyparDecl + ([], SynTypar (TError, None, false), [], + { AmpersandRanges = [] })], [], (1,17--1,29))), + [], [MyResult], + PreXmlDoc ((1,4), FSharp.Compiler.Xml.XmlDocCollector), + true, None, (1,9--1,17)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (Ok, None), + Fields + [SynField + ([], false, Some ResultValue, + Var (SynTypar (T, None, false), (4,26--4,28)), + false, + PreXmlDoc ((4,14), FSharp.Compiler.Xml.XmlDocCollector), + None, (4,14--4,28), { LeadingKeyword = None })], + PreXmlDoc ((4,6), FSharp.Compiler.Xml.XmlDocCollector), + None, (3,6--4,28), { BarRange = Some (4,6--4,7) }); + SynUnionCase + ([], SynIdent (Error, None), + Fields + [SynField + ([], false, Some ErrorValue, + Var + (SynTypar (TError, None, false), + (7,28--7,35)), false, + PreXmlDoc ((7,17), FSharp.Compiler.Xml.XmlDocCollector), + None, (7,17--7,35), { LeadingKeyword = None })], + PreXmlDoc ((7,6), FSharp.Compiler.Xml.XmlDocCollector), + None, (6,6--7,35), { BarRange = Some (7,6--7,7) })], + (3,6--7,35)), (3,6--7,35)), [], None, (1,9--7,35), + { LeadingKeyword = Type (1,4--1,8) + EqualsRange = Some (1,30--1,31) + WithKeyword = None })], (1,4--7,35))], PreXmlDocEmpty, [], + None, (1,4--7,35), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/SignatureInAbstractMember.fs b/tests/service/data/SyntaxTree/Nullness/SignatureInAbstractMember.fs new file mode 100644 index 00000000000..9839c9cd370 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/SignatureInAbstractMember.fs @@ -0,0 +1,2 @@ +type MyClassBase1() = + abstract member function1 : string | null -> string | null diff --git a/tests/service/data/SyntaxTree/Nullness/SignatureInAbstractMember.fs.bsl b/tests/service/data/SyntaxTree/Nullness/SignatureInAbstractMember.fs.bsl new file mode 100644 index 00000000000..b7cfdabef4f --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/SignatureInAbstractMember.fs.bsl @@ -0,0 +1,60 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/SignatureInAbstractMember.fs", false, + QualifiedNameOfFile SignatureInAbstractMember, [], [], + [SynModuleOrNamespace + ([SignatureInAbstractMember], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [MyClassBase1], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,17)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], SimplePats ([], [], (1,17--1,19)), None, + PreXmlDoc ((1,17), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,17), { AsKeyword = None }); + AbstractSlot + (SynValSig + ([], SynIdent (function1, None), + SynValTyparDecls (None, true), + Fun + (WithNull + (LongIdent + (SynLongIdent ([string], [], [None])), false, + (2,31--2,44)), + WithNull + (LongIdent + (SynLongIdent ([string], [], [None])), false, + (2,48--2,61)), (2,31--2,61), + { ArrowRange = (2,45--2,47) }), + SynValInfo + ([[SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), false, false, + PreXmlDoc ((2,3), FSharp.Compiler.Xml.XmlDocCollector), + None, None, (2,3--2,61), + { LeadingKeyword = + AbstractMember ((2,3--2,11), (2,12--2,18)) + InlineKeyword = None + WithKeyword = None + EqualsRange = None }), + { IsInstance = true + IsDispatchSlot = true + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, (2,3--2,61), + { GetSetKeywords = None })], (2,3--2,61)), [], + Some + (ImplicitCtor + (None, [], SimplePats ([], [], (1,17--1,19)), None, + PreXmlDoc ((1,17), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,17), { AsKeyword = None })), (1,5--2,61), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,20--1,21) + WithKeyword = None })], (1,0--2,61))], PreXmlDocEmpty, [], + None, (1,0--3,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/StringOrNull.fs b/tests/service/data/SyntaxTree/Nullness/StringOrNull.fs new file mode 100644 index 00000000000..f27f3c86f09 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/StringOrNull.fs @@ -0,0 +1 @@ +let x : string | null = null diff --git a/tests/service/data/SyntaxTree/Nullness/StringOrNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/StringOrNull.fs.bsl new file mode 100644 index 00000000000..f73e3f6ab3a --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/StringOrNull.fs.bsl @@ -0,0 +1,31 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/StringOrNull.fs", false, QualifiedNameOfFile StringOrNull, + [], [], + [SynModuleOrNamespace + ([StringOrNull], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None, + None), Named (SynIdent (x, None), false, None, (1,4--1,5)), + Some + (SynBindingReturnInfo + (WithNull + (LongIdent (SynLongIdent ([string], [], [None])), + false, (1,8--1,21)), (1,8--1,21), [], + { ColonRange = Some (1,6--1,7) })), + Typed + (Null (1,24--1,28), + WithNull + (LongIdent (SynLongIdent ([string], [], [None])), false, + (1,8--1,21)), (1,24--1,28)), (1,4--1,5), Yes (1,0--1,28), + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,22--1,23) })], (1,0--1,28))], + PreXmlDocEmpty, [], None, (1,0--2,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/StringOrNullInFunctionArg.fs b/tests/service/data/SyntaxTree/Nullness/StringOrNullInFunctionArg.fs new file mode 100644 index 00000000000..37569d4900a --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/StringOrNullInFunctionArg.fs @@ -0,0 +1 @@ +let myFunc (x: (string | null)) = 42 diff --git a/tests/service/data/SyntaxTree/Nullness/StringOrNullInFunctionArg.fs.bsl b/tests/service/data/SyntaxTree/Nullness/StringOrNullInFunctionArg.fs.bsl new file mode 100644 index 00000000000..c10d17ee85f --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/StringOrNullInFunctionArg.fs.bsl @@ -0,0 +1,36 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/StringOrNullInFunctionArg.fs", false, + QualifiedNameOfFile StringOrNullInFunctionArg, [], [], + [SynModuleOrNamespace + ([StringOrNullInFunctionArg], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None, None), + LongIdent + (SynLongIdent ([myFunc], [], [None]), None, None, + Pats + [Paren + (Typed + (Named + (SynIdent (x, None), false, None, (1,12--1,13)), + Paren + (WithNull + (LongIdent + (SynLongIdent ([string], [], [None])), + false, (1,16--1,29)), (1,15--1,30)), + (1,12--1,30)), (1,11--1,31))], None, (1,4--1,31)), + None, Const (Int32 42, (1,34--1,36)), (1,4--1,31), NoneAtLet, + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,32--1,33) })], (1,0--1,36))], + PreXmlDocEmpty, [], None, (1,0--2,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Nullness/TypeAbbreviationAddingWithNull.fs b/tests/service/data/SyntaxTree/Nullness/TypeAbbreviationAddingWithNull.fs new file mode 100644 index 00000000000..194814afffa --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/TypeAbbreviationAddingWithNull.fs @@ -0,0 +1 @@ +type MyFlatOption = string | null \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/Nullness/TypeAbbreviationAddingWithNull.fs.bsl b/tests/service/data/SyntaxTree/Nullness/TypeAbbreviationAddingWithNull.fs.bsl new file mode 100644 index 00000000000..1a874cb67b7 --- /dev/null +++ b/tests/service/data/SyntaxTree/Nullness/TypeAbbreviationAddingWithNull.fs.bsl @@ -0,0 +1,24 @@ +ImplFile + (ParsedImplFileInput + ("/root/Nullness/TypeAbbreviationAddingWithNull.fs", false, + QualifiedNameOfFile TypeAbbreviationAddingWithNull, [], [], + [SynModuleOrNamespace + ([TypeAbbreviationAddingWithNull], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [MyFlatOption], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,17)), + Simple + (TypeAbbrev + (Ok, + WithNull + (LongIdent (SynLongIdent ([string], [], [None])), + false, (1,20--1,33)), (1,20--1,33)), (1,20--1,33)), + [], None, (1,5--1,33), { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,18--1,19) + WithKeyword = None })], (1,0--1,33))], + PreXmlDocEmpty, [], None, (1,0--1,33), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + CodeComments = [] }, set []))