Skip to content

Commit f3ce54c

Browse files
authored
Fix issue accessing prop with interop matching builtin name (#897)
Hi, can you please review patch to fix issue with accessing interop properties when they match a builtins name. It fixes #896. This seems like a simple fix to simply to ignore munging builtins names when accessing interop properties, it does not seem we want it to apply here. I've also added a test. Thanks Co-authored-by: ikappaki <[email protected]>
1 parent 7be69bb commit f3ce54c

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
* Fix a bug where the original `(var ...)` form is not retained during analysis, causing it to be lost in calls to `macroexpand` (#888)
3535
* Fix issue with the reader var macro failing in syntax quote when unquoting a symbol, e.g. `(#'~symbol) (#889)
3636
* Fix issue where `(str seq)` was printing seq string items without quotation marks (#891)
37+
* Fix issue where interop failed to access property name matching a builtins name (#896)
3738

3839
## [v0.1.0b1]
3940
### Added

src/basilisp/lang/compiler/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3247,7 +3247,7 @@ def _interop_prop_to_py_ast(
32473247
return GeneratedPyAST(
32483248
node=ast.Attribute(
32493249
value=target_ast.node,
3250-
attr=munge(node.field),
3250+
attr=munge(node.field, True),
32513251
ctx=ast.Store() if is_assigning else ast.Load(),
32523252
),
32533253
dependencies=target_ast.dependencies,

tests/basilisp/compiler_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3332,6 +3332,13 @@ def test_interop_prop(self, lcompile: CompileFn):
33323332
assert "sym" == lcompile("(.-name 'some.ns/sym)")
33333333
assert "sym" == lcompile("(.- 'some.ns/sym name)")
33343334
assert "sym" == lcompile("(. 'some.ns/sym -name)")
3335+
assert 5 == lcompile(
3336+
'(.-abc (python/type "ip-test" (python/tuple) #py {"abc" 5}))'
3337+
)
3338+
# when prop name matches a bultins name
3339+
assert 6 == lcompile(
3340+
'(.-str (python/type "ip-test" (python/tuple) #py {"str" 6}))'
3341+
)
33353342

33363343
with pytest.raises(AttributeError):
33373344
lcompile("(.-fake 'some.ns/sym)")

0 commit comments

Comments
 (0)