Merge branch 'h/kwargs-need-value-fix'

Closes #815, #821, #822.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This commit is contained in:
Gergely Nagy 2015-08-11 10:57:17 +02:00
commit 4834b59cba
No known key found for this signature in database
GPG Key ID: 0A083C5F06E0DD42
2 changed files with 13 additions and 2 deletions

View File

@ -459,8 +459,9 @@ class HyASTCompiler(object):
try: try:
value = next(exprs_iter) value = next(exprs_iter)
except StopIteration: except StopIteration:
msg = "Keyword argument {kw} needs a value" raise HyTypeError(expr,
raise HyCompileError(msg.format(kw=str(expr))) "Keyword argument {kw} needs "
"a value.".format(kw=str(expr[1:])))
compiled_value = self.compile(value) compiled_value = self.compile(value)
ret += compiled_value ret += compiled_value

View File

@ -439,6 +439,16 @@ def test_lambda_list_keywords_mixed():
" (list x xs kwxs kwoxs))") " (list x xs kwxs kwoxs))")
def test_missing_keyword_argument_value():
"""Ensure the compiler chokes on missing keyword argument values."""
try:
can_compile("((fn [x] x) :x)")
except HyTypeError as e:
assert(e.message == "Keyword argument :x needs a value.")
else:
assert(False)
def test_ast_unicode_strings(): def test_ast_unicode_strings():
"""Ensure we handle unicode strings correctly""" """Ensure we handle unicode strings correctly"""