A code generation library for Gleam
2

Configure Feed

Select the types of activity you want to include in your feed.

Fix recursive generic functions

Gears (Apr 14, 2026, 4:52 PM +0100) e25fbfc7 e1456f4e

+27 -2
+11
birdie_snapshots/recursive_generic_function.accepted
··· 1 + --- 2 + version: 1.5.4 3 + title: recursive_generic_function 4 + file: ./test/trick_test.gleam 5 + test_name: recursive_generic_function_test 6 + --- 7 + pub fn swap(a: a, b: b) -> f { 8 + swap(b, a) 9 + } 10 + 11 +
+1 -2
src/trick.gleam
··· 2237 2237 let type_ = 2238 2238 Function(parameters: parameter_types, return: return_type, field_map: None) 2239 2239 2240 - let expression = 2241 - doc_to_expression(Compiled(doc.from_string(name), type_, precedence_unit)) 2240 + let expression = instantiated(doc.from_string(name), type_, precedence_unit) 2242 2241 2243 2242 let body = continue(expression) 2244 2243
+15
test/trick_test.gleam
··· 1724 1724 |> unwrap 1725 1725 |> birdie.snap("custom_type_used_in_function_parameter") 1726 1726 } 1727 + 1728 + pub fn recursive_generic_function_test() { 1729 + { 1730 + use _ <- trick.function("swap", trick.Public, { 1731 + use a <- trick.parameter("a", trick.generic("a")) 1732 + use b <- trick.parameter("b", trick.generic("b")) 1733 + use swap <- trick.recursive 1734 + swap |> trick.call([b, a]) |> trick.expression 1735 + }) 1736 + trick.end_module() 1737 + } 1738 + |> trick.to_string 1739 + |> unwrap 1740 + |> birdie.snap("recursive_generic_function") 1741 + }