Merge pull request #1799 from Kodiologist/kwp
Remove some exceptions in keyword parsing
This commit is contained in:
commit
d6ae646c66
2
NEWS.rst
2
NEWS.rst
@ -8,6 +8,8 @@ Removals
|
||||
* Python 2 is no longer supported.
|
||||
* Support for attribute lists in `defclass` has been removed. Use `setv`
|
||||
and `defn` instead.
|
||||
* Literal keywords are no longer parsed differently in calls to functions
|
||||
with certain names.
|
||||
|
||||
Bug Fixes
|
||||
------------------------------
|
||||
|
@ -1664,11 +1664,7 @@ class HyASTCompiler(object):
|
||||
if not func:
|
||||
func = self.compile(root)
|
||||
|
||||
# An exception for pulling together keyword args is if we're doing
|
||||
# a typecheck, eg (type :foo)
|
||||
with_kwargs = root not in (
|
||||
"type", "HyKeyword", "keyword", "name", "keyword?", "identity")
|
||||
args, ret, keywords = self._compile_collect(args, with_kwargs)
|
||||
args, ret, keywords = self._compile_collect(args, with_kwargs=True)
|
||||
|
||||
return func + ret + asty.Call(
|
||||
expr, func=func.expr, args=args, keywords=keywords)
|
||||
|
@ -634,8 +634,8 @@ result['y in globals'] = 'y' in globals()")
|
||||
"NATIVE: testing the keyword? function"
|
||||
(assert (keyword? ':bar))
|
||||
(assert (keyword? ':baz))
|
||||
(assert (keyword? :bar))
|
||||
(assert (keyword? :baz))
|
||||
(setv x :bar)
|
||||
(assert (keyword? x))
|
||||
(assert (not (keyword? "foo")))
|
||||
(assert (not (keyword? ":foo")))
|
||||
(assert (not (keyword? 1)))
|
||||
|
@ -1104,7 +1104,8 @@
|
||||
|
||||
(assert (= :foo :foo))
|
||||
(assert (= :foo ':foo))
|
||||
(assert (is (type :foo) (type ':foo)))
|
||||
(setv x :foo)
|
||||
(assert (is (type x) (type ':foo)))
|
||||
(assert (= (get {:foo "bar"} :foo) "bar"))
|
||||
(assert (= (get {:bar "quux"} (get {:foo :bar} :foo)) "quux")))
|
||||
|
||||
@ -1119,9 +1120,9 @@
|
||||
(defn test-empty-keyword []
|
||||
"NATIVE: test that the empty keyword is recognized"
|
||||
(assert (= : :))
|
||||
(assert (keyword? :))
|
||||
(assert (keyword? ':))
|
||||
(assert (!= : ":"))
|
||||
(assert (= (name :) "")))
|
||||
(assert (= (name ':) "")))
|
||||
|
||||
|
||||
(defn test-nested-if []
|
||||
@ -1198,12 +1199,15 @@
|
||||
5j 5.1j 2+1j 1.2+3.4j
|
||||
"" b""
|
||||
"apple bloom" b"apple bloom" "⚘" b"\x00"
|
||||
:mykeyword
|
||||
[] #{} {}
|
||||
[1 2 3] #{1 2 3} {"a" 1 "b" 2}]]
|
||||
(assert (= (eval `(identity ~x)) x))
|
||||
(assert (= (eval x) x)))
|
||||
|
||||
(setv kw :mykeyword)
|
||||
(assert (= (get (eval `[~kw]) 0) kw))
|
||||
(assert (= (eval kw) kw))
|
||||
|
||||
; Tuples wrap to HyLists, not HyExpressions.
|
||||
(assert (= (eval (,)) []))
|
||||
(assert (= (eval (, 1 2 3)) [1 2 3]))
|
||||
@ -1632,7 +1636,8 @@ macros()
|
||||
(assert (= (keyword 'foo) :foo))
|
||||
(assert (= (keyword 'foo-bar) :foo-bar))
|
||||
(assert (= (keyword 1) :1))
|
||||
(assert (= (keyword :foo_bar) :foo-bar)))
|
||||
(setv x :foo_bar)
|
||||
(assert (= (keyword x) :foo-bar)))
|
||||
|
||||
(defn test-name-conversion []
|
||||
"NATIVE: Test name conversion"
|
||||
@ -1644,8 +1649,8 @@ macros()
|
||||
(assert (= (name 'foo_bar) "foo-bar"))
|
||||
(assert (= (name 1) "1"))
|
||||
(assert (= (name 1.0) "1.0"))
|
||||
(assert (= (name :foo) "foo"))
|
||||
(assert (= (name :foo_bar) "foo-bar"))
|
||||
(assert (= (name ':foo) "foo"))
|
||||
(assert (= (name ':foo_bar) "foo-bar"))
|
||||
(assert (= (name test-name-conversion) "test-name-conversion")))
|
||||
|
||||
(defn test-keywords []
|
||||
|
Loading…
Reference in New Issue
Block a user