diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index e2943c80013b5b77adb9e29eb307ab15ad7964f2..dc35c124cb235a033d407265b328aa869f0f7ab3 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -984,12 +984,13 @@ checkAPat msg loc e0 = do | extopt LangExt.NPlusKPatterns opts && (plus == plus_RDR) -> return (mkNPlusKPat (L nloc n) (L lloc lit)) - OpApp l op _fix r -> do l <- checkLPat msg l - r <- checkLPat msg r - case op of - L cl (HsVar (L _ c)) | isDataOcc (rdrNameOcc c) - -> return (ConPatIn (L cl c) (InfixCon l r)) - _ -> patFail msg loc e0 + OpApp l (L cl (HsVar (L _ c))) _fix r + | isDataOcc (rdrNameOcc c) -> do + l <- checkLPat msg l + r <- checkLPat msg r + return (ConPatIn (L cl c) (InfixCon l r)) + + OpApp _l _op _fix _r -> patFail msg loc e0 HsPar e -> checkLPat msg e >>= (return . ParPat) ExplicitList _ _ es -> do ps <- mapM (checkLPat msg) es diff --git a/testsuite/tests/parser/should_fail/InfixAppPatErr.hs b/testsuite/tests/parser/should_fail/InfixAppPatErr.hs new file mode 100644 index 0000000000000000000000000000000000000000..5a56f711eb383565830265e8d010b45bab3e2271 --- /dev/null +++ b/testsuite/tests/parser/should_fail/InfixAppPatErr.hs @@ -0,0 +1,5 @@ +main = do + f $ do + a <- return 3 + c <- do + return 5 diff --git a/testsuite/tests/parser/should_fail/InfixAppPatErr.stderr b/testsuite/tests/parser/should_fail/InfixAppPatErr.stderr new file mode 100644 index 0000000000000000000000000000000000000000..69839e3920c480c801c72a0ca57f08df2f951a62 --- /dev/null +++ b/testsuite/tests/parser/should_fail/InfixAppPatErr.stderr @@ -0,0 +1,4 @@ + +InfixAppPatErr.hs:2:3: error: + Parse error in pattern: f $ do a <- return 3 c + Possibly caused by a missing 'do'? diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T index 2cb9c49de20abe19d00554199ac34cec571f661c..d47e0f57965ac72bc2f6cb27148a1053a2bb9943 100644 --- a/testsuite/tests/parser/should_fail/all.T +++ b/testsuite/tests/parser/should_fail/all.T @@ -115,3 +115,5 @@ test('NumericUnderscoresFail0', grep_errmsg(r'^NumericUnderscoresFail0.hs:'), compile_fail, ['']) test('NumericUnderscoresFail1', grep_errmsg(r'^NumericUnderscoresFail1.hs:'), compile_fail, ['']) + +test('InfixAppPatErr', normal, compile_fail, [''])