From 01ecfd21c66200401a632c1494239e4d2b4e3918 Mon Sep 17 00:00:00 2001 From: David Holland Date: Mon, 6 Jan 2025 17:22:22 -0500 Subject: [PATCH] Allow function types in records without parentheses. There's no syntactic reason to demand the parentheses. Closes #1994. Include a test. --- CHANGES.md | 3 +++ intTests/test1994/test.saw | 1 + intTests/test1994/test.sh | 3 +++ src/SAWScript/Parser.y | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 intTests/test1994/test.saw create mode 100644 intTests/test1994/test.sh diff --git a/CHANGES.md b/CHANGES.md index 25407be8a3..b08f2c50f4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,9 @@ ## Bug fixes +* Function types in records no longer require gratuitous parentheses. +(#1994) + * Unexpected special-case type behavior of monad binds in the syntactic top level has been removed. (This was _not_ specifically associated with the TopLevel monad, so diff --git a/intTests/test1994/test.saw b/intTests/test1994/test.saw new file mode 100644 index 0000000000..6b84234e60 --- /dev/null +++ b/intTests/test1994/test.saw @@ -0,0 +1 @@ +let thing : { fn: Int -> Int } = { fn = \x -> x }; diff --git a/intTests/test1994/test.sh b/intTests/test1994/test.sh new file mode 100644 index 0000000000..2315cc233c --- /dev/null +++ b/intTests/test1994/test.sh @@ -0,0 +1,3 @@ +set -e + +$SAW test.saw diff --git a/src/SAWScript/Parser.y b/src/SAWScript/Parser.y index 38d305da57..d1d7d3d255 100644 --- a/src/SAWScript/Parser.y +++ b/src/SAWScript/Parser.y @@ -214,7 +214,7 @@ Type :: { Type } | BaseType '->' Type { tFun (maxSpan [$1, $3]) $1 $3 } FieldType :: { (Name, Type) } - : name ':' BaseType { (tokStr $1, $3) } + : name ':' Type { (tokStr $1, $3) } BaseType :: { Type } : name { tVar (getPos $1) (tokStr $1) }