From 24efbdfb7cee2fe06dcd0bbec8397e0d01641e4e Mon Sep 17 00:00:00 2001 From: Jean Klingler Date: Sat, 8 Jul 2023 17:24:01 +0900 Subject: [PATCH] Document whitespace rules for keyword syntax (#12773) --- lib/elixir/pages/references/syntax-reference.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/elixir/pages/references/syntax-reference.md b/lib/elixir/pages/references/syntax-reference.md index 3129479326..7820eb9a9a 100644 --- a/lib/elixir/pages/references/syntax-reference.md +++ b/lib/elixir/pages/references/syntax-reference.md @@ -470,6 +470,8 @@ Atoms with foreign characters, such as whitespace, must be wrapped in quotes. Th Remember that, because lists and two-element tuples are quoted literals, by definition keywords are also literals (in fact, the only reason tuples with two elements are quoted literals is to support keywords as literals). +In order to be valid keyword syntax, `:` cannot be preceded by any whitespace (`foo : 1` is invalid) and has to be followed by whitespace (`foo:1` is invalid). + ### Keywords as last arguments Elixir also supports a syntax where if the last argument of a call is a keyword list then the square brackets can be skipped. This means that the following: