Skip to content
  • skvadrik's avatar
    4 reduce/reduce parser conflicts resolved · 697079f1
    skvadrik authored and Ben Gamari's avatar Ben Gamari committed
    As GHC documentation (section 7.4.4, Type operators) says:
    > "There is now some potential ambiguity in import and export lists;
    for example if you write import M( (+) ) do you mean the function (+)
    or the type constructor (+)? The default is the former, but with
    -XExplicitNamespaces (which is implied by -XExplicitTypeOperators) GHC
    allows you to specify the latter by preceding it with the keyword type"
    
    Turns out this ambiguity causes 4 of 6 reduce/reduce conflicts in GHC
    parser.  All 4 conflicts arise from a single production:
    
        qcname
            :  qvar
            |  oqtycon
    
    Recursive inlining of 'qvar' and 'oqtycon' helps reveal the faulty
    productions:
    
        qcname
            :
        ...
            | '(' QVARSYM ')'
            | '(' VARSYM ')'
            | '(' '*'    ')'
            | '(' '-'    ')'
    
    These productions can either be parsed as variable or type constructor,
    but variable constuctor is always preferred. My patch removes ambiguity
    while preserving the existing behaviour:
    
      - all unambigous productions are left as-is
      - ambigous productions for variable constuctors are left
      - ambigous productions for type constructors are removed (there's no
        way they could be triggered)
    
    Updated comment.
    
    Test Plan: Tested with 'make fasttest'
    
    Reviewers: austin, simonpj, trofi, bgamari, simonmar
    
    Reviewed By: trofi, bgamari, simonmar
    
    Subscribers: thomie, mpickering
    
    Projects: #ghc
    
    Differential Revision: https://phabricator.haskell.org/D1111
    697079f1