-
Notifications
You must be signed in to change notification settings - Fork 215
Convert incomplete pattern warnings to compile-time errors #2186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…mplete-patterns Co-authored-by: amitaibu <125707+amitaibu@users.noreply.github.com>
Co-authored-by: amitaibu <125707+amitaibu@users.noreply.github.com>
Co-authored-by: amitaibu <125707+amitaibu@users.noreply.github.com>
Added the flag to both ihp.cabal and ihp-ide.cabal in the shared-properties section so that incomplete patterns are caught during CI builds of the framework itself, not just in consumer applications. Also restored the FailureHtml pattern that was removed in testing. Co-authored-by: amitaibu <125707+amitaibu@users.noreply.github.com>
You're right - the flag was only in Fixed in commit 110d575 by adding Now CI will catch incomplete patterns in both framework code and app code. |
|
Added missing UrlInput case to the second pattern match in bootstrap4's styledFormField function. This was revealed by the -Werror=incomplete-patterns flag added to the cabal files. Co-authored-by: amitaibu <125707+amitaibu@users.noreply.github.com>
✅ Fix Incomplete Patterns and Enable Strict Pattern Checking
This PR addresses issue #2291 by converting
-Wincomplete-patternswarnings to compile-time errors and fixing all incomplete patterns in the IHP framework.🎯 Problem Statement
IHP had
-Wincomplete-patternsas a warning, which was easily overlooked. This led to incomplete pattern matches in the codebase (ValidateField.hs and MigrationGenerator.hs as shown in the issue screenshots), which could cause runtime errors if new constructors are added.✨ Solution
-fwarn-incomplete-patterns→-Werror=incomplete-patternsfor app code-Werror=incomplete-patternstoihp.cabalandihp-ide.cabalfor framework code📝 Detailed Changes
1. ValidateField.hs
Fixed: Missing
FailureHtmlcase inwithCustomErrorMessage2. MigrationGenerator.hs
Fixed 7 partial pattern matches by converting
(Just x) =bindings to proper case expressions with error handling.3. CSSFramework.hs (NEW)
Fixed: Missing
UrlInputcase in bootstrap4'sstyledFormFieldfunction (line 464)4. Makefile.dist
Changed from
-fwarn-incomplete-patternsto-Werror=incomplete-patternswith documentation.5. ihp.cabal & ihp-ide.cabal
Added to
shared-propertiessection:ghc-options: -Werror=incomplete-patterns -Werror=missing-fieldsThis ensures the framework code itself is checked during CI builds, not just consumer applications.
🔧 How Consumers Can Override
Option 1 - Per-module basis:
{-# OPTIONS_GHC -Wno-error=incomplete-patterns #-} module MyModule whereOption 2 - Project-wide in Makefile:
GHC_EXTENSIONS+= -Wno-error=incomplete-patterns✅ Testing & Verification
📊 Impact
Files changed: 6
ihp/IHP/ValidationSupport/ValidateField.hs: Fixed FailureHtml patternihp-ide/IHP/IDE/CodeGen/MigrationGenerator.hs: Fixed 7 partial patternsihp/IHP/View/CSSFramework.hs: Fixed UrlInput patternihp-ide/data/lib/IHP/Makefile.dist: Changed flag for app codeihp/ihp.cabal: Added flag for framework buildsihp-ide/ihp-ide.cabal: Added flag for IDE framework buildsNet result: Both framework and applications now catch incomplete patterns at compile-time! 🎉
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.