Merge pull request #96 from madjar/default-args-in-atpattern
Fix a bug where defaultargs are absent from the atpattern argument
This commit is contained in:
commit
9cd901fc4b
|
@ -98,9 +98,10 @@ buildArgument paramSpec arg = either error id $ case paramSpec of
|
|||
let actualParamSet = case paramSet of
|
||||
FixedParamSet s -> s
|
||||
VariadicParamSet s -> s
|
||||
maybeAddSet = case setName of
|
||||
Just name -> Map.insert name arg
|
||||
Nothing -> id
|
||||
maybeAddSet attrsSet = case setName of
|
||||
Just name -> let Fix (NVSet argSet) = arg
|
||||
in Map.insert name (Fix (NVSet (argSet `Map.union` attrsSet))) attrsSet
|
||||
Nothing -> attrsSet
|
||||
in maybeAddSet <$> lookupParamSet actualParamSet
|
||||
where
|
||||
go env k def = maybe (Left err) return $ Map.lookup k env <|> def
|
||||
|
|
|
@ -42,6 +42,9 @@ case_function_atpattern = constantEqualStr "2" "(({a}@attrs:attrs) {a=2;}).a"
|
|||
case_function_ellipsis :: Assertion
|
||||
case_function_ellipsis = constantEqualStr "2" "(({a, ...}@attrs:attrs) {a=0; b=2;}).b"
|
||||
|
||||
case_function_default_value_in_atpattern :: Assertion
|
||||
case_function_default_value_in_atpattern = constantEqualStr "2" "({a ? 2}@attrs:attrs.a) {}"
|
||||
|
||||
tests :: TestTree
|
||||
tests = $testGroupGenerator
|
||||
|
||||
|
|
Loading…
Reference in a new issue