From efbbb67b8bf0dcedab2af148c99f3badc1212ee3 Mon Sep 17 00:00:00 2001 From: "Sean T. Allen" Date: Sun, 1 Mar 2026 08:56:43 -0500 Subject: [PATCH] Add \exhaustive\ annotation to exhaustive match blocks Ponyc recently added an \exhaustive\ annotation for match expressions. When present, the compiler will fail compilation if the match is not exhaustive. This protects against future breakage if new variants are added to a union type. --- appdirs/_test.pony | 16 ++++++++-------- appdirs/appdirs.pony | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/appdirs/_test.pony b/appdirs/_test.pony index 89c3456..0d31c60 100644 --- a/appdirs/_test.pony +++ b/appdirs/_test.pony @@ -54,7 +54,7 @@ primitive \nodoc\ _AppDirsTestUtil h: TestHelper, loc: SourceLoc = __loc) ? => - match expected.home_dir + match \exhaustive\ expected.home_dir | _ExpectError => h.assert_error( {()? => app_dirs.user_home_dir()? } @@ -65,7 +65,7 @@ primitive \nodoc\ _AppDirsTestUtil app_dirs.user_home_dir()? where loc = loc) end - match expected.user_data_dir + match \exhaustive\ expected.user_data_dir | _ExpectError => h.assert_error( {()? => app_dirs.user_data_dir()? } @@ -76,7 +76,7 @@ primitive \nodoc\ _AppDirsTestUtil app_dirs.user_data_dir()? where loc = loc) end - match expected.site_data_dirs + match \exhaustive\ expected.site_data_dirs | _ExpectError => h.assert_error( {()? => app_dirs.site_data_dirs()? } @@ -88,7 +88,7 @@ primitive \nodoc\ _AppDirsTestUtil where loc = loc) end - match expected.user_config_dir + match \exhaustive\ expected.user_config_dir | _ExpectError => h.assert_error( {()? => app_dirs.user_config_dir()? } @@ -99,7 +99,7 @@ primitive \nodoc\ _AppDirsTestUtil app_dirs.user_config_dir()? where loc = loc) end - match expected.site_config_dirs + match \exhaustive\ expected.site_config_dirs | _ExpectError => h.assert_error( {()? => app_dirs.site_config_dirs()? } @@ -111,7 +111,7 @@ primitive \nodoc\ _AppDirsTestUtil where loc = loc) end - match expected.user_cache_dir + match \exhaustive\ expected.user_cache_dir | _ExpectError => h.assert_error( {()? => app_dirs.user_cache_dir()? } @@ -123,7 +123,7 @@ primitive \nodoc\ _AppDirsTestUtil where loc = loc) end - match expected.user_state_dir + match \exhaustive\ expected.user_state_dir | _ExpectError => h.assert_error( {()? => app_dirs.user_state_dir()? } @@ -135,7 +135,7 @@ primitive \nodoc\ _AppDirsTestUtil where loc = loc) end - match expected.user_log_dir + match \exhaustive\ expected.user_log_dir | _ExpectError => h.assert_error( {()? => app_dirs.user_log_dir()? } diff --git a/appdirs/appdirs.pony b/appdirs/appdirs.pony index d47f578..e9c629e 100644 --- a/appdirs/appdirs.pony +++ b/appdirs/appdirs.pony @@ -37,7 +37,7 @@ type _Maybe[T] is (T | None) primitive _Opt fun get[T](s: _Maybe[T], or_else: T): T => - match consume s + match \exhaustive\ consume s | let value: T => consume value | None => consume or_else end @@ -126,7 +126,7 @@ class AppDirs dir for this application. """ let os_specific_dir = - match _platform + match \exhaustive\ _platform | _Osx => Paths.join( [ _home as String @@ -153,7 +153,7 @@ class AppDirs "" end end - match _app_version + match \exhaustive\ _app_version | None => os_specific_dir | let v: String => Path.join(os_specific_dir, v) end @@ -175,7 +175,7 @@ class AppDirs data dirs for this application. """ let os_specific_dirs: Array[String] iso = - match _platform + match \exhaustive\ _platform | _Osx => recover [ Path.join( @@ -239,7 +239,7 @@ class AppDirs for this application. """ let os_specific_dir = - match _platform + match \exhaustive\ _platform | _Osx => Paths.join( [ _home as String @@ -254,7 +254,7 @@ class AppDirs end // apply version - match _app_version + match \exhaustive\ _app_version | None => os_specific_dir | let v: String => Path.join(os_specific_dir, v) @@ -275,7 +275,7 @@ class AppDirs for this application. """ let os_specific_dirs: Array[String] iso = - match _platform + match \exhaustive\ _platform | _Osx => recover [ Path.join( @@ -326,7 +326,7 @@ class AppDirs for this application. """ let os_specific_dir = - match _platform + match \exhaustive\ _platform | _Osx => Paths.join( [ _home as String @@ -351,7 +351,7 @@ class AppDirs "" end end - match _app_version + match \exhaustive\ _app_version | None => os_specific_dir | let v: String => Path.join(os_specific_dir, v) end @@ -371,7 +371,7 @@ class AppDirs See: https://wiki.debian.org/XDGBaseDirectorySpecification#state """ - match _platform + match \exhaustive\ _platform | _Osx | _Windows => user_data_dir()? | _OsxAsUnix | _Unix => @@ -393,7 +393,7 @@ class AppDirs Return full path to the user-specific log dir for this application. """ - match _platform + match \exhaustive\ _platform | _Osx => Paths.join( [ _home as String