Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to release/dev17.10 #16782

Merged
merged 8 commits into from
Feb 28, 2024
2 changes: 2 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.300.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Fix wrong range start of INTERP_STRING_END. ([PR #16774](https://github.com/dotnet/fsharp/pull/16774))
* Fix missing warning for recursive calls in list comprehensions. ([PR #16652](https://github.com/dotnet/fsharp/pull/16652))
* Code generated files with > 64K methods and generated symbols crash when loaded. Use infered sequence points for debugging. ([Issue #16399](https://github.com/dotnet/fsharp/issues/16399), [#PR 16514](https://github.com/dotnet/fsharp/pull/16514))
* `nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16550](https://github.com/dotnet/fsharp/pull/16550), [PR #16743](https://github.com/dotnet/fsharp/pull/16743))
Expand All @@ -11,6 +12,7 @@
* `[<CliEvent>]` member should not produce property symbol. ([Issue #16640](https://github.com/dotnet/fsharp/issues/16640), [PR #16658](https://github.com/dotnet/fsharp/pull/16658))
* Fix discriminated union initialization. ([#PR 16661](https://github.com/dotnet/fsharp/pull/16661))
* Allow calling method with both Optional and ParamArray. ([#PR 16688](https://github.com/dotnet/fsharp/pull/16688), [suggestions #1120](https://github.com/fsharp/fslang-suggestions/issues/1120))
* Fix release inline optimization, which leads to MethodAccessException if used with `assembly:InternalsVisibleTo`` attribute. ([Issue #16105](https://github.com/dotnet/fsharp/issues/16105), ([PR #16737](https://github.com/dotnet/fsharp/pull/16737))
* Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692))

### Added
Expand Down
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.24123.3">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.24127.2">
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
<Sha>62fb9a85e5c4af657b0014fd6d6588c139d0bb4f</Sha>
<Sha>6d28b5a26876f8f22dadb8f6cdee878faaa88464</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<!-- Intermediate is necessary for source build. -->
Expand All @@ -30,9 +30,9 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24113.2">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24123.1">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>da98edc4c3ea539f109ea320672136ceb32591a7</Sha>
<Sha>042763a811fd94dc3556253d4c64118dd665216e</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23475.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
Expand Down
2 changes: 1 addition & 1 deletion eng/common/templates/steps/generate-sbom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# IgnoreDirectories - Directories to ignore for SBOM generation. This will be passed through to the CG component detector.

parameters:
PackageVersion: 7.0.0
PackageVersion: 8.0.0
BuildDropPath: '$(Build.SourcesDirectory)/artifacts'
PackageName: '.NET'
ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"perl": "5.38.0.1"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24113.2",
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24123.1",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
43 changes: 34 additions & 9 deletions src/Compiler/Optimize/Optimizer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ let rec IsPartialExprVal x =
| TupleValue args | RecdValue (_, args) | UnionCaseValue (_, args) -> Array.exists IsPartialExprVal args
| ConstValue _ | CurriedLambdaValue _ | ConstExprValue _ -> false
| ValValue (_, a)
| SizeValue(_, a) -> IsPartialExprVal a
| SizeValue (_, a) -> IsPartialExprVal a

let CheckInlineValueIsComplete (v: Val) res =
if v.MustInline && IsPartialExprVal res then
Expand Down Expand Up @@ -690,10 +690,25 @@ let GetInfoForVal cenv env m (vref: ValRef) =
GetInfoForLocalValue cenv env vref.binding m
else
GetInfoForNonLocalVal cenv env vref
res

let GetInfoForValWithCheck cenv env m (vref: ValRef) =
let res = GetInfoForVal cenv env m vref
check vref res |> ignore
res

let IsPartialExpr cenv env m x =
let rec isPartialExpression x =
match x with
| Expr.App (func, _, _, args, _) -> func :: args |> Seq.exists isPartialExpression
| Expr.Lambda (_, _, _, _, expr, _, _) -> expr |> isPartialExpression
| Expr.Let (TBind (_,expr,_), body, _, _) -> expr :: [body] |> List.exists isPartialExpression
| Expr.LetRec (bindings, body, _, _) -> body :: (bindings |> List.map (fun (TBind (_,expr,_)) -> expr)) |> List.exists isPartialExpression
| Expr.Sequential (expr1, expr2, _, _) -> [expr1; expr2] |> Seq.exists isPartialExpression
| Expr.Val (vr, _, _) when not vr.IsLocalRef -> ((GetInfoForVal cenv env m vr).ValExprInfo) |> IsPartialExprVal
| _ -> false
isPartialExpression x

//-------------------------------------------------------------------------
// Try to get information about values of particular types
//-------------------------------------------------------------------------
Expand Down Expand Up @@ -3062,11 +3077,14 @@ and TryOptimizeVal cenv env (vOpt: ValRef option, mustInline, inlineIfLambda, va
failwith "tuple, union and record values cannot be marked 'inline'"

| UnknownValue when mustInline ->
warning(Error(FSComp.SR.optValueMarkedInlineHasUnexpectedValue(), m)); None
warning(Error(FSComp.SR.optValueMarkedInlineHasUnexpectedValue(), m))
None

| _ when mustInline ->
warning(Error(FSComp.SR.optValueMarkedInlineCouldNotBeInlined(), m)); None
| _ -> None
warning(Error(FSComp.SR.optValueMarkedInlineCouldNotBeInlined(), m))
None

| _ -> None

and TryOptimizeValInfo cenv env m vinfo =
if vinfo.HasEffect then None else TryOptimizeVal cenv env (None, false, false, vinfo.Info, m)
Expand All @@ -3089,7 +3107,7 @@ and OptimizeVal cenv env expr (v: ValRef, m) =

let g = cenv.g

let valInfoForVal = GetInfoForVal cenv env m v
let valInfoForVal = GetInfoForValWithCheck cenv env m v

match TryOptimizeVal cenv env (Some v, v.MustInline, v.InlineIfLambda, valInfoForVal.ValExprInfo, m) with
| Some e ->
Expand Down Expand Up @@ -3402,15 +3420,15 @@ and TryInlineApplication cenv env finfo (tyargs: TType list, args: Expr list, m)
| _ -> false
| _ -> false
| _ -> false
| _ -> false
| _ -> false

if isValFromLazyExtensions then None else

let isSecureMethod =
match finfo.Info with
| ValValue(vref, _) ->
vref.Attribs |> List.exists (fun a -> (IsSecurityAttribute g cenv.amap cenv.casApplied a m) || (IsSecurityCriticalAttribute g a))
| _ -> false
| _ -> false

if isSecureMethod then None else

Expand All @@ -3421,6 +3439,13 @@ and TryInlineApplication cenv env finfo (tyargs: TType list, args: Expr list, m)

if isGetHashCode then None else

let isApplicationPartialExpr =
match finfo.Info with
| ValValue (_, CurriedLambdaValue (_, _, _, expr, _) ) -> IsPartialExpr cenv env m expr
| _ -> false

if isApplicationPartialExpr then None else

// Inlining lambda
let f2R = CopyExprForInlining cenv false f2 m

Expand Down Expand Up @@ -3597,8 +3622,8 @@ and OptimizeApplication cenv env (f0, f0ty, tyargs, args, m) =
// This includes recursive calls to the function being defined (in which case we get a non-critical, closed-world tailcall).
// Note we also have to check the argument count to ensure this is a direct call (or a partial application).
let doesNotMakeCriticalTailcall =
vref.MakesNoCriticalTailcalls ||
(let valInfoForVal = GetInfoForVal cenv env m vref in valInfoForVal.ValMakesNoCriticalTailcalls) ||
vref.MakesNoCriticalTailcalls ||
(let valInfoForVal = GetInfoForValWithCheck cenv env m vref in valInfoForVal.ValMakesNoCriticalTailcalls) ||
(match env.functionVal with | None -> false | Some (v, _) -> valEq vref.Deref v)
if doesNotMakeCriticalTailcall then
let numArgs = otherArgs.Length + newArgs.Length
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Service/FSharpCheckerResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2685,7 +2685,7 @@ module internal ParseAndCheckFile =
| INTERP_STRING_BEGIN_PART _ | INTERP_STRING_PART _ as tok, _ ->
let braceOffset =
match tok with
| INTERP_STRING_BEGIN_PART(_, SynStringKind.TripleQuote, (LexerContinuation.Token(_, (_, _, dl, _) :: _))) ->
| INTERP_STRING_BEGIN_PART(_, SynStringKind.TripleQuote, (LexerContinuation.Token(_, (_, _, dl, _, _) :: _))) ->
dl - 1
| _ -> 0

Expand Down
12 changes: 6 additions & 6 deletions src/Compiler/Service/ServiceLexing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module FSharpTokenTag =
tagOfToken (INTERP_STRING_BEGIN_PART("a", SynStringKind.Regular, LexCont.Default))

let INTERP_STRING_PART = tagOfToken (INTERP_STRING_PART("a", LexCont.Default))
let INTERP_STRING_END = tagOfToken (INTERP_STRING_END("a", LexCont.Default))
let INTERP_STRING_END = tagOfToken (INTERP_STRING_END("a", None, LexCont.Default))
let LPAREN = tagOfToken LPAREN
let RPAREN = tagOfToken RPAREN
let LBRACK = tagOfToken LBRACK
Expand Down Expand Up @@ -493,7 +493,7 @@ module internal LexerStateEncoding =
| INTERP_STRING_BEGIN_PART(_, _, cont)
| INTERP_STRING_PART(_, cont)
| INTERP_STRING_BEGIN_END(_, _, cont)
| INTERP_STRING_END(_, cont)
| INTERP_STRING_END(_, _, cont)
| LBRACE cont
| RBRACE cont
| BYTEARRAY(_, _, cont)
Expand Down Expand Up @@ -621,12 +621,12 @@ module internal LexerStateEncoding =
let tag1, i1, kind1, rest =
match stringNest with
| [] -> false, 0, 0, []
| (i1, kind1, _, _) :: rest -> true, i1, encodeStringStyle kind1, rest
| (i1, kind1, _, _, _) :: rest -> true, i1, encodeStringStyle kind1, rest

let tag2, i2, kind2 =
match rest with
| [] -> false, 0, 0
| (i2, kind2, _, _) :: _ -> true, i2, encodeStringStyle kind2
| (i2, kind2, _, _, _) :: _ -> true, i2, encodeStringStyle kind2

(if tag1 then 0b100000000000 else 0)
||| (if tag2 then 0b010000000000 else 0)
Expand Down Expand Up @@ -696,9 +696,9 @@ module internal LexerStateEncoding =
let nest =
[
if tag1 then
i1, decodeStringStyle kind1, 0, range0
i1, decodeStringStyle kind1, 0, None, range0
if tag2 then
i2, decodeStringStyle kind2, 0, range0
i2, decodeStringStyle kind2, 0, None, range0
]

nest
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/LexHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ type LexerStringFinisher =
else if isPart then
INTERP_STRING_PART(s, cont)
else
INTERP_STRING_END(s, cont)
INTERP_STRING_END(s, None, cont)
elif kind.IsByteString then
let synByteStringKind =
if isVerbatim then
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/SyntaxTree/ParseHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ type LexerStringKind =

/// Represents the degree of nesting of '{..}' and the style of the string to continue afterwards, in an interpolation fill.
/// Nesting counters and styles of outer interpolating strings are pushed on this stack.
type LexerInterpolatedStringNesting = (int * LexerStringStyle * int * range) list
type LexerInterpolatedStringNesting = (int * LexerStringStyle * int * range option * range) list

/// The parser defines a number of tokens for whitespace and
/// comments eliminated by the lexer. These carry a specification of
Expand Down Expand Up @@ -973,7 +973,7 @@ let checkEndOfFileError t =

match nesting with
| [] -> ()
| (_, _, _, m) :: _ -> reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedStringFill ())
| (_, _, _, _, m) :: _ -> reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedStringFill ())

type BindingSet = BindingSetPreAttrs of range * bool * bool * (SynAttributes -> SynAccess option -> SynAttributes * SynBinding list) * range

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/ParseHelpers.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ type LexerStringKind =

static member String: LexerStringKind

type LexerInterpolatedStringNesting = (int * LexerStringStyle * int * range) list
type LexerInterpolatedStringNesting = (int * LexerStringStyle * int * range option * range) list

[<RequireQualifiedAccess; NoComparison; NoEquality>]
type LexerContinuation =
Expand Down
Loading
Loading