Skip to content
Merged
Changes from all commits
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
8 changes: 4 additions & 4 deletions src/FsYacc.Core/fsyaccdriver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,6 @@ let writeSpecToFile (generatorState: GeneratorState) (spec: ParserSpec) (compile

writer.WriteLine "#nowarn \"1182\" // the generated code often has unused variable 'parseState'"

writer.WriteLine
"#nowarn \"3261\" // the generated code would need to properly annotate nulls, e.g. changing System.Object to `obj|null`"

for s in generatorState.opens do
writer.WriteLine "open %s" s
writer.WriteLineInterface "open %s" s
Expand Down Expand Up @@ -371,7 +368,10 @@ let writeSpecToFile (generatorState: GeneratorState) (spec: ParserSpec) (compile
| None -> "")
(match typ with
| Some _ -> "Microsoft.FSharp.Core.Operators.box _fsyacc_x"
| None -> "(null : System.Object)")
// We can't use null here because if all tokens are untyped, the function will be generic.
// We used to use (null : obj) but that leads to warnings when nullable reference types are enabled.
// box null does the right thing regardless of NRT and gets optimized to a single ldnull.
| None -> "Microsoft.FSharp.Core.Operators.box null")

for key, _ in spec.Types |> Seq.countBy fst |> Seq.filter (fun (_, n) -> n > 1) do
failwithf "%s is given multiple %%type declarations" key
Expand Down
Loading