packages feed

aihc-cpp 2.0.0.1 → 2.0.0.2

raw patch · 7 files changed

+32/−23 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -4,6 +4,18 @@  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [2.0.0.2] - 2026-11-28++### Fixed++- A directive inside a Haskell block comment (`{- ... -}`) is now live, as+  it is with GHC. GHC runs the system C preprocessor, which does not know+  Haskell comments. Previously such a directive was ignored, which broke+  modules such as `streamly-core`, that define macros in a `{- ... -}`+  comment. A directive inside a C block comment (`/* ... */`) is still+  ignored. This behavior deliberately differs from `cpphs`, thus the two+  `cpphs` oracle fixtures for directives in a Haskell comment are removed.+ ## [2.0.0.1] - 2026-11-15  ### Fixed
aihc-cpp.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.8 name: aihc-cpp-version: 2.0.0.1+version: 2.0.0.2 build-type: Simple license: Unlicense license-file: LICENSE
src/Aihc/Cpp.hs view
@@ -432,9 +432,13 @@       hasTrailingNl = trailingNl && not (atEnd restCursor) || (trailingNl && atEnd restCursor)       -- Actually: trailingNl flag is set at processFile entry for includes.       -- We just propagate it. The check at atEnd above handles the final empty line.-      startsInBlockComment = stHsBlockCommentDepth st > 0 || stCBlockCommentDepth st > 0+      -- Only a C block comment hides a directive. GHC runs the system C+      -- preprocessor, which does not know Haskell comments. Thus a directive+      -- inside @{- ... -}@ is live, and real modules depend on it (for+      -- example, streamly-core defines its mode constants in such a comment).+      startsInCBlockComment = stCBlockCommentDepth st > 0       parsedDirective =-        if startsInBlockComment+        if startsInCBlockComment           then Nothing           else parseDirective lineText       isActive = currentActive stack
test/Spec.hs view
@@ -411,24 +411,30 @@           (C.unlines ["#line 1 \"<input>\"", "", "", "h = (3) + ((3))"])     ] +-- | GHC runs the system C preprocessor, which does not know Haskell+-- comments. Thus a directive inside @{- ... -}@ is live. Each expected+-- output is the output of @ghc -E -cpp@ for the same input. pragmaInsideBlockCommentTests :: TestTree pragmaInsideBlockCommentTests =   testGroup-    "pragma inside a Haskell block comment"-    [ testCase "#-} does not close the enclosing comment" $+    "directive inside a Haskell block comment"+    [ testCase "#define inside a comment defines the macro" $+        assertPreprocessOutput+          (C.unlines ["{-", "#define S_IXUSR 00100", "-}", "x = S_IXUSR"])+          (C.unlines ["#line 1 \"<input>\"", "{-", "", "-}", "x = 00100"]),+      testCase "#if 0 inside a comment removes its lines" $         case preprocess defaultConfig pragmaInBlockCommentInput of           Done result -> do             resultDiagnostics result @?= []             resultOutput result-              @?= "#line 1 \"<input>\"\n{-\n#if 0\n{-# INLINABLE foo #-}\n#endif\n-}\nlive\n"+              @?= "#line 1 \"<input>\"\n{-\n\n\n\n-}\nlive\n"           _ -> assertFailure "expected Done",-      testCase "commented-out #if 0 does not delete live code" $+      testCase "a pragma inside a comment does not stop the next directives" $         case preprocess defaultConfig pragmaInBlockCommentElseInput of           Done result -> do             resultDiagnostics result @?= []-            if "kept" `C.isInfixOf` resultOutput result-              then pure ()-              else assertFailure ("expected commented-out branch to stay intact, got: " <> show (resultOutput result))+            resultOutput result+              @?= "#line 1 \"<input>\"\n{-\n{-# INLINABLE foo #-}\n\n\n\nalso kept\n\n-}\nlive\n"           _ -> assertFailure "expected Done"     ] 
− test/Test/Fixtures/progress/macro-in-comment-with-line-comment-marker.hs
@@ -1,6 +0,0 @@-#define A 1-{---- line comment marker inside block comment-#define B 2--}-A B
− test/Test/Fixtures/progress/macro-in-comment.hs
@@ -1,5 +0,0 @@-#define A 1-{--#define B 2--}-A B
test/Test/Fixtures/progress/manifest.tsv view
@@ -26,10 +26,8 @@ line-directive-number-only	diagnostics	line-directive-number-only.hs	pass language-pragma-closing-line	lexing	language-pragma-closing-line.hs	pass indented-hash-operator	lexing	indented-hash-operator.hs	pass-macro-in-comment	lexing	macro-in-comment.hs	pass macro-in-inline-block-comment	lexing	macro-in-inline-block-comment.hs	pass macro-in-line-comment	lexing	macro-in-line-comment.hs	pass-macro-in-comment-with-line-comment-marker	lexing	macro-in-comment-with-line-comment-marker.hs	pass unterminated-string-in-comment	lexing	unterminated-string-in-comment.hs	pass comment-stripping-c89	lexing	comment-stripping-c89.hs	pass predefined-in-string	macro	predefined-in-string.hs	pass