Can't compile on GHC 9.4.3 (Ambiguous record field - error)
maerten opened this issue · 3 comments
Hello,
it seems that compiling on GHC 9.4 fails. Possibly related to: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7639
hal > configure
hal > Configuring hal-1.0.0...
hal > build
hal > Preprocessing library for hal-1.0.0..
hal > Building library for hal-1.0.0..
hal > [ 1 of 15] Compiling AWS.Lambda.Combinators
hal > [ 2 of 15] Compiling AWS.Lambda.Context
hal > [ 3 of 15] Compiling AWS.Lambda.Events.ApiGateway.ProxyRequest
hal >
hal > /private/var/folders/0c/zmpjp7l568xcvnt49pkkn5p00000gn/T/stack-db91f9e3e880fddf/hal-1.0.0/src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:97:28: error:
hal > Ambiguous occurrence ‘path’
hal > It could refer to
hal > either the field ‘path’ of record ‘ProxyRequest’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:155:7
hal > or the field ‘path’ of record ‘RequestContext’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:64:7
hal > |
hal > 97 | [ Just $ "path" .= path (r :: RequestContext a)
hal > | ^^^^
hal >
hal > [ 4 of 15] Compiling AWS.Lambda.Events.ApiGateway.ProxyResponse
hal > /private/var/folders/0c/zmpjp7l568xcvnt49pkkn5p00000gn/T/stack-db91f9e3e880fddf/hal-1.0.0/src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:98:33: error:
hal > Ambiguous occurrence ‘accountId’
hal > It could refer to
hal > either the field ‘accountId’ of record ‘RequestContext’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:65:7
hal > or the field ‘accountId’ of record ‘Identity’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:46:7
hal > |
hal > 98 | , Just $ "accountId" .= accountId (r :: RequestContext a)
hal > | ^^^^^^^^^
hal >
hal > /private/var/folders/0c/zmpjp7l568xcvnt49pkkn5p00000gn/T/stack-db91f9e3e880fddf/hal-1.0.0/src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:107:34: error:
hal > Ambiguous occurrence ‘httpMethod’
hal > It could refer to
hal > either the field ‘httpMethod’ of record ‘ProxyRequest’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:162:7
hal > or the field ‘httpMethod’ of record ‘RequestContext’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:74:7
hal > |
hal > 107 | , Just $ "httpMethod" .= httpMethod (r :: RequestContext a)
hal > | ^^^^^^^^^^
hal >
hal > /private/var/folders/0c/zmpjp7l568xcvnt49pkkn5p00000gn/T/stack-db91f9e3e880fddf/hal-1.0.0/src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:207:28: error:
hal > Ambiguous occurrence ‘path’
hal > It could refer to
hal > either the field ‘path’ of record ‘ProxyRequest’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:155:7
hal > or the field ‘path’ of record ‘RequestContext’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:64:7
hal > |
hal > 207 | [ Just $ "path" .= path (r :: ProxyRequest a)
hal > | ^^^^
hal >
hal > /private/var/folders/0c/zmpjp7l568xcvnt49pkkn5p00000gn/T/stack-db91f9e3e880fddf/hal-1.0.0/src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:218:34: error:
hal > Ambiguous occurrence ‘httpMethod’
hal > It could refer to
hal > either the field ‘httpMethod’ of record ‘ProxyRequest’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:162:7
hal > or the field ‘httpMethod’ of record ‘RequestContext’,
hal > defined at src/AWS/Lambda/Events/ApiGateway/ProxyRequest.hs:74:7
hal > |
hal > 218 | , Just $ "httpMethod" .= httpMethod (r :: ProxyRequest a)
hal > | ^^^^^^^^^^
hal >
hal > /private/var/folders/0c/zmpjp7l568xcvnt49pkkn5p00000gn/T/stack-db91f9e3e880fddf/hal-1.0.0/src/AWS/Lambda/Events/ApiGateway/ProxyResponse.hs:162:16: warning: [-Wredundant-constraints]
hal > Redundant constraint: Eq k
hal > In the type signature for:
hal > toCIHashMap :: forall k a.
hal > (Eq k, FoldCase k, Hashable k) =>
hal > HashMap k a -> HashMap (CI k) a
hal > |
hal > 162 | toCIHashMap :: (Eq k, FoldCase k, Hashable k) => HashMap k a -> HashMap (CI k) a
hal > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hal > [ 5 of 15] Compiling AWS.Lambda.Events.EventBridge
hal > [ 6 of 15] Compiling AWS.Lambda.Events.EventBridge.Detail.SSM.ParameterStoreChange
hal > [ 7 of 15] Compiling AWS.Lambda.Events.Kafka
hal > [ 8 of 15] Compiling AWS.Lambda.Events.S3
hal > [ 9 of 15] Compiling AWS.Lambda.Events.SQS
hal > [10 of 15] Compiling AWS.Lambda.Internal
hal > [11 of 15] Compiling AWS.Lambda.RuntimeClient.Internal
hal > [12 of 15] Compiling AWS.Lambda.RuntimeClient
hal > [13 of 15] Compiling AWS.Lambda.Runtime.Value
hal > [14 of 15] Compiling AWS.Lambda.Runtime
hal > [15 of 15] Compiling Paths_hal
Thanks for reporting this! And appreciate the leg work on finding the related issue, that really helps. I've got a PR #115 going that will get 9.4 into CI (and picks up some others).
I was hoping this one would be a simple one, but I currently can't see a way to use selectors at all if two records define the same selector in the same module.
As of GHC 9.4.1, selector names have to be entirely unambiguous.
and
An unqualified name "x" is unambiguous if and only if there is just one "x" in scope unqualified.
The DisambiguateRecordFields
only has an effect on matching and constructing, no effect on selectors.
I'll keep looking into this, hopefully there's a way to make this work without a breaking change.
Just released 1.0.0.1 which fixes this issue, and 9.4 is now part of the CI. Answer was to use pattern matching, as GHC can still disambiguate that.
Thanks again for the report!
Wow that was fast, thanks for fixing it!