basilisp-lang / basilisp

A Clojure-compatible(-ish) Lisp dialect targeting Python 3.8+
https://basilisp.readthedocs.io
Eclipse Public License 1.0
256 stars 6 forks source link

issue when accessing interop properties whose name matches builtin names #896

Closed ikappaki closed 5 months ago

ikappaki commented 5 months ago

Hi,

there's an issue when accessing some object property names with interop that match builtins names, such as str "AttributeError: type object 'xyz' has no attribute 'str_'"

To reproduce

  1. Open up the REPL and create an object from a class that has a property with the name str
    basilisp.user=> (def x (python/type "xyz" (python/tuple) #py {"abc" 5 "str" 6}))
    #'basilisp.user/x
  2. try to access the property using interop, it errors out
    basilisp.user=> (.-str x)
    Traceback (most recent call last):
    File "C:\src\basilisp\src\basilisp\cli.py", line 447, in repl
    result = eval_str(lsrc, ctx, ns, eof)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\src\basilisp\src\basilisp\cli.py", line 46, in eval_str
    last = compiler.compile_and_exec_form(form, ctx, ns)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\src\basilisp\src\basilisp\lang\compiler\__init__.py", line 191, in compile_and_exec_form
    return getattr(ns.module, final_wrapped_name)()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<REPL Input>", line 1, in __lisp_expr___74
    AttributeError: type object 'xyz' has no attribute 'str_'

The same succeeds for abc property whose name is not the same as a builtin identifier

basilisp.user=> (.-abc x)
5

PR to follow.