Skip to content

Commit 46777e9

Browse files
authored
Fix a bug where deftype names could not be called if they contain a dash (#778)
Fixes #777
1 parent f063c90 commit 46777e9

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### Fixed
1717
* Fix issue with `(count nil)` throwing an exception (#759)
18-
* Fix issue with keyword fn not testing for test membership in sets (#762)
18+
* Fix issue with keywords not testing for membership in sets when used as a function (#762)
1919
* Fix an issue for executing Basilisp scripts via a shebang where certain platforms may not support more than one argument in the shebang line (#764)
20-
* Fix issue with keyword fns throwing type error on vectors (#770)
20+
* Fix issue with keywords throwing `TypeError` when used as a function on vectors (#770)
21+
* Fix an issue where the constructors of types created by `deftype` and `defrecord` could not be called if they contained `-` characters (#777)
2122

2223
## [v0.1.0b0]
2324
### Added

src/basilisp/lang/compiler/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ def _deftype_to_py_ast( # pylint: disable=too-many-locals
14641464
_load_attr(_NS_VAR_VALUE),
14651465
ast.Call(
14661466
func=_NEW_SYM_FN_NAME,
1467-
args=[ast.Constant(type_name)],
1467+
args=[ast.Constant(node.name)],
14681468
keywords=[],
14691469
),
14701470
ast.Name(id=type_name, ctx=ast.Load()),

tests/basilisp/compiler_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,12 @@ def test_deftype_interface_must_be_abstract(
609609
with pytest.raises(ExceptionType):
610610
lcompile(code)
611611

612+
def test_deftype_name_can_contain_dashes(self, lcompile: CompileFn):
613+
cls = lcompile("(deftype* three-axis-point [x y z])")
614+
o = lcompile("(three-axis-point. 1 2 3)")
615+
assert isinstance(o, cls)
616+
assert (o.x, o.y, o.z) == (1, 2, 3)
617+
612618
def test_deftype_allows_empty_abstract_interface(self, lcompile: CompileFn):
613619
Point = lcompile(
614620
"""

0 commit comments

Comments
 (0)