diff options
author | Björn Gustavsson <[email protected]> | 2014-02-14 13:02:26 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2014-02-17 13:31:19 +0100 |
commit | cf72119ea1b76a8650503a8ca2b1e025e9c7b700 (patch) | |
tree | ff7921a776736c2b97b8b45bbf6c74db2e32f915 /lib/stdlib/src/edlin_expand.erl | |
parent | 1d4affb9f61f7ea832c534f57d50872d5a1d3376 (diff) | |
download | otp-cf72119ea1b76a8650503a8ca2b1e025e9c7b700.tar.gz otp-cf72119ea1b76a8650503a8ca2b1e025e9c7b700.tar.bz2 otp-cf72119ea1b76a8650503a8ca2b1e025e9c7b700.zip |
Correct parenthesis expansion
Commit dfb4ec804a099b539c91e5643090d8183885e71c attempted to add
a closing parenthesis to the expansion of a funtion of zero arity
if there were no other functions with the same name.
Unfortunately it would add the closing parenthesis in many cases
when there was another function with another name (e.g. to
Mod:module_info/0 even though there is a Mod:module_info/1).
Correct logic for adding parenthesis and add a test case.
Diffstat (limited to 'lib/stdlib/src/edlin_expand.erl')
-rw-r--r-- | lib/stdlib/src/edlin_expand.erl | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/stdlib/src/edlin_expand.erl b/lib/stdlib/src/edlin_expand.erl index 0033010dce..a2b4663219 100644 --- a/lib/stdlib/src/edlin_expand.erl +++ b/lib/stdlib/src/edlin_expand.erl @@ -73,7 +73,7 @@ to_atom(Str) -> error end. -match(Prefix, Alts, Extra) -> +match(Prefix, Alts, Extra0) -> Len = length(Prefix), Matches = lists:sort( [{S, A} || {H, A} <- Alts, @@ -89,13 +89,11 @@ match(Prefix, Alts, Extra) -> {yes, Remain, []} end; {complete, Str} -> - {_, Arity} = lists:keyfind(Str, 1, Matches), - case {Arity, Extra} of - {0, "("} -> - {yes, nthtail(Len, Str) ++ "()", []}; - _ -> - {yes, nthtail(Len, Str) ++ Extra, []} - end; + Extra = case {Extra0,Matches} of + {"(",[{Str,0}]} -> "()"; + {_,_} -> Extra0 + end, + {yes, nthtail(Len, Str) ++ Extra, []}; no -> {no, [], []} end. |