summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@dashbit.co>2020-02-04 13:24:45 +0100
committerJosé Valim <jose.valim@dashbit.co>2020-02-04 13:25:02 +0100
commitb9e2d38bb63175c421b7f5fa475c29abdf568365 (patch)
treede757ea5f52dc7a1ec5561608e17c99001d4e120
parent2532c37d1535d42632b220b0a263bb9b5424545d (diff)
downloadelixir-b9e2d38bb63175c421b7f5fa475c29abdf568365.tar.gz
Only warn for commas at the end of words
-rw-r--r--lib/elixir/lib/kernel.ex3
-rw-r--r--lib/elixir/test/elixir/kernel/sigils_test.exs2
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/elixir/lib/kernel.ex b/lib/elixir/lib/kernel.ex
index 24534298b..3528feef6 100644
--- a/lib/elixir/lib/kernel.ex
+++ b/lib/elixir/lib/kernel.ex
@@ -5432,7 +5432,8 @@ defmodule Kernel do
true ->
parts = String.split(string)
- parts_with_trailing_comma = :lists.filter(&(:binary.last(&1) == ?,), parts)
+ parts_with_trailing_comma =
+ :lists.filter(&(byte_size(&1) > 1 and :binary.last(&1) == ?,), parts)
if parts_with_trailing_comma != [] do
stacktrace = Macro.Env.stacktrace(caller)
diff --git a/lib/elixir/test/elixir/kernel/sigils_test.exs b/lib/elixir/test/elixir/kernel/sigils_test.exs
index c1dbe47b2..04a95b9c5 100644
--- a/lib/elixir/test/elixir/kernel/sigils_test.exs
+++ b/lib/elixir/test/elixir/kernel/sigils_test.exs
@@ -66,6 +66,7 @@ bar) in ["foo\\\nbar", "foo\\\r\nbar"]
test "sigil w" do
assert ~w() == []
+ assert ~w([ , ]) == ["[", ",", "]"]
assert ~w(foo bar baz) == ["foo", "bar", "baz"]
assert ~w(foo #{:bar} baz) == ["foo", "bar", "baz"]
@@ -100,6 +101,7 @@ bar) in ["foo\\\nbar", "foo\\\r\nbar"]
test "sigil W" do
assert ~W() == []
+ assert ~W([ , ]) == ["[", ",", "]"]
assert ~W(foo #{bar} baz) == ["foo", "\#{bar}", "baz"]
assert ~W(foo\ bar) == ["foo\\", "bar"]