Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PrintFormat: capture fields should be immutable
  • Loading branch information
Yatao Li committed Jul 3, 2019
commit f75ab75e24c02cd395c57d8263c2fc0a12009603
27 changes: 10 additions & 17 deletions src/fsharp/FSharp.Core/printf.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@

namespace Microsoft.FSharp.Core

type PrintfFormat<'Printer,'State,'Residue,'Result>(value:string) =

internal new(value, caps, types) as this =
PrintfFormat<_,_,_,_>(value)
then this.Captures <- caps
this.Types <- types

member __.Value = value
member val internal Captures: obj[] = Unchecked.defaultof<obj[]> with get, set
member val internal Types: System.Type[] = Unchecked.defaultof<System.Type[]> with get, set
override __.ToString() = value

type PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>(value:string) =
inherit PrintfFormat<'Printer,'State,'Residue,'Result>(value)
internal new(value, caps) as this =
PrintfFormat<_,_,_,_,_>(value)
then this.Captures <- caps
type PrintfFormat<'Printer,'State,'Residue,'Result>(value: string, captures: obj[], types: Type[]) =
new(value) = new PrintfFormat<'Printer,'State,'Residue,'Result>(value, null, null)
member __.Value = value
member __.Captures = captures
member __.Types = types
override __.ToString() = value

type PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>(value: string, captures: obj[], types: Type[]) =
inherit PrintfFormat<'Printer,'State,'Residue,'Result>(value, captures, types)
new(value) = new PrintfFormat<'Printer,'State,'Residue,'Result, 'Tuple>(value, null, null)

type Format<'Printer,'State,'Residue,'Result> = PrintfFormat<'Printer,'State,'Residue,'Result>
type Format<'Printer,'State,'Residue,'Result,'Tuple> = PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>
Expand Down