Skip to content

fsyacc conflict reports cannot be suppressed and flood the build log #241

Description

@nojaf

fsyacc prints every shift/reduce and reduce/reduce conflict to stdout unconditionally, and there is no way to turn it off.

The reports come from reportConflict in src/FsYacc.Core/fsyaccast.fs:

printfn
    "        %s/%s error at state %d on terminal %s between %s and %s - assuming the former because %s"

Nothing guards that call, and none of the options in src/FsYacc/fsyacc.fs reduce output. The closest is -v, which adds a listing file rather than removing anything.

Why it matters

For the F# compiler grammar (pars.fsy) this is 1457 lines on every regeneration: 617 shift/reduce and 840 reduce/reduce. Because CallFsYacc in FsLexYacc.targets runs a plain <Exec> with no importance set, all of it lands in the MSBuild log at normal verbosity and buries everything else the build has to say.

These conflicts are a property of the grammar. For someone authoring a grammar they are worth seeing. For someone vendoring a grammar they do not control, which is Fantomas' case with dotnet/fsharp's pars.fsy, they are noise on every build and carry no action.

Possible resolutions

Any of these would solve it:

  • a --quiet or --no-conflict-report flag on fsyacc
  • routing the conflict reports into the listing file that -v already produces, instead of stdout
  • printing a summary by default, for example 617 shift/reduce, 840 reduce/reduce conflicts, pass -v for detail, with the per state detail behind -v

The third seems the most useful of the three, since what a grammar author actually wants to notice is the count changing, not 1457 individual lines scrolling past.

Workaround

Setting StandardOutputImportance="low" on the <Exec> in CallFsYacc hides the reports at normal verbosity while keeping them available at -v:detailed. That is what Fantomas does through a Directory.Build.targets override. It could reasonably be the package default: the reports are not actionable for the great majority of consumers, and the escape hatch costs nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions