Skip to content

Commit 5e231fd

Browse files
KevinRansombaronfel
authored andcommitted
Merge pull request #8498 from KevinRansom/michalmocarski
Michal mocarski's fix
2 parents c5e0749 + a2ee308 commit 5e231fd

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/absil/il.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ type ILVersionInfo =
309309
new (major, minor, build, revision) =
310310
{ Major = major; Minor = minor; Build = build; Revision = revision }
311311

312+
/// For debugging
313+
override x.ToString() = sprintf "ILVersionInfo: %u %u %u %u" (x.Major) (x.Minor) (x.Build) (x.Revision)
314+
315+
312316
type Locale = string
313317

314318
[<StructuralEquality; StructuralComparison>]

src/fsharp/fsc.fs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,24 @@ module MainModuleBuilder =
837837
v
838838

839839
let productVersionToILVersionInfo (version: string) : ILVersionInfo =
840-
let parseOrZero v = match System.UInt16.TryParse v with (true, i) -> i | (false, _) -> 0us
840+
let parseOrZero i (v:string) =
841+
let v =
842+
// When i = 3 then this is the 4th part of the version. The last part of the version can be trailed by any characters so we trim them off
843+
if i <> 3 then
844+
v
845+
else
846+
((false, ""), v)
847+
||> Seq.fold(fun (finished, v) c ->
848+
match finished with
849+
| false when Char.IsDigit(c) -> false, v + c.ToString()
850+
| _ -> true, v)
851+
|> snd
852+
match System.UInt16.TryParse v with
853+
| (true, i) -> i
854+
| (false, _) -> 0us
841855
let validParts =
842856
version.Split('.')
843-
|> Seq.map parseOrZero
844-
|> Seq.takeWhile ((<>) 0us)
857+
|> Array.mapi(fun i v -> parseOrZero i v)
845858
|> Seq.toList
846859
match validParts @ [0us; 0us; 0us; 0us] with
847860
| major :: minor :: build :: rev :: _ -> ILVersionInfo(major, minor, build, rev)

0 commit comments

Comments
 (0)