Changes between Version 2 and Version 3 of Migration/8.10


Ignore:
Timestamp:
Feb 14, 2019 4:00:34 PM (7 months ago)
Author:
RyanGlScott
Comment:

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

Legend:

Unmodified
Added
Removed
Modified
  • Migration/8.10

    v2 v3  
    88== Compiler changes
    99
    10 TODO
     10=== New RecordWildCards warnings
     11
     12GHC 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:
     13
     14{{{#!hs
     15{-# LANGUAGE NamedFieldPuns #-}
     16{-# LANGUAGE RecordWildCards #-}
     17{-# OPTIONS_GHC -Wall #-}
     18
     19data P = P { x :: Int, y :: Int }
     20
     21f1 :: P -> Int
     22f1 P{..} = 1 + 3
     23
     24f2 :: P -> Int
     25f2 P{x,y,..} = x + y
     26}}}
     27
     28{{{
     29Foo.hs:8:6: warning: [-Wunused-record-wildcards]
     30    No variables bound in the record wildcard match are used
     31      Possible fix: omit the ‘..’
     32  |
     338 | f1 P{..} = 1 + 3
     34  |      ^^
     35
     36Foo.hs:11:10: warning: [-Wredundant-record-wildcards]
     37    Record wildcard does not bind any new variables
     38      Possible fix: omit the ‘..’
     39   |
     4011 | f2 P{x,y,..} = x + y
     41   |          ^^
     42}}}
     43
     44To fix the warnings, simply remove the uses of `..`, as neither use is necessary.
    1145
    1246--------------------------------