wiki:Migration/8.10

Version 3 (modified by RyanGlScott, 7 months ago) (diff)

-Wunused-record-wildcards and -Wredundant-record-wildcards

GHC 8.10.x Migration Guide

This guide summarises the changes you may need to make to your code to migrate from GHC 8.8 to GHC 8.10. This guide complements the GHC 8.10.x release notes which should be consulted as well.


Compiler changes

New RecordWildCards warnings

GHC 8.10 introduces two new flags, -Wunused-record-wildcards and -Wredundant-record-wildcards, which are implied by -Wall. This means that certain programs that use RecordWildCards will trigger warnings that did not do so previously. For instance, the following program emits no warnings on old versions of GHC, but will warn with GHC 8.10:

{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -Wall #-}

data P = P { x :: Int, y :: Int }

f1 :: P -> Int
f1 P{..} = 1 + 3

f2 :: P -> Int
f2 P{x,y,..} = x + y
Foo.hs:8:6: warning: [-Wunused-record-wildcards]
    No variables bound in the record wildcard match are used
      Possible fix: omit the ‘..’
  |
8 | f1 P{..} = 1 + 3
  |      ^^

Foo.hs:11:10: warning: [-Wredundant-record-wildcards]
    Record wildcard does not bind any new variables
      Possible fix: omit the ‘..’
   |
11 | f2 P{x,y,..} = x + y
   |          ^^

To fix the warnings, simply remove the uses of .., as neither use is necessary.


Library changes

TODO