Skip to content

Commit

Permalink
Forbid Symbol("#foo")
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Jun 9, 2023
1 parent e48f92f commit 9916b7d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Bug Fixes
* The parser no longer looks for shebangs in the REPL or `hy -c`.
* `require` with relative module names should now work correctly with
`hy -m`, as well as `hy2py`'s recursive mode.
* `hy.models.Symbol` no longer allows constructing a symbol beginning
with `#`.

New Features
------------------------------
Expand Down
2 changes: 1 addition & 1 deletion hy/reader/hy_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def err(msg):
if reader is None:
if (
not ident
or ident[:1] == ":"
or ident[0] in ":#"
or any(isnormalizedspace(c) for c in ident)
or HyReader.NON_IDENT.intersection(ident)
):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def test_symbol_or_keyword():
for x in ("foo", "foo-bar", "foo_bar", "✈é😂⁂"):
assert str(Symbol(x)) == x
assert Keyword(x).name == x
for x in ("", ":foo", "5"):
for x in ("", ":foo", "5", "#foo"):
# https://github.com/hylang/hy/issues/2383
with pytest.raises(ValueError):
Symbol(x)
assert Keyword(x).name == x
Expand Down

0 comments on commit 9916b7d

Please sign in to comment.