Skip to content

Commit c835374

Browse files
chrisrink10Christopher Rink
andauthored
Retain the original (var ...) form during analyis (#890)
Fixes #888 --------- Co-authored-by: Christopher Rink <[email protected]>
1 parent 43d2e26 commit c835374

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
* Fix a bug where names `def`'ed without reader metadata would cause the compiler to throw an exception (#850)
3131
* Fix an issue where `concat` on maps was iterating over the keys instead of the key/value pairs (#871)
3232
* Fix a bug where the compiler would throw an exception partially macroexpanding forms with `recur` forms provided as arguments (#856)
33+
* Fix a bug where the original `(var ...)` form is not retained during analysis, causing it to be lost in calls to `macroexpand` (#888)
3334

3435
## [v0.1.0b1]
3536
### Added

src/basilisp/lang/compiler/analyzer.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,7 +1703,9 @@ def __deftype_and_reify_impls_are_all_abstract( # pylint: disable=too-many-loca
17031703
"and cannot be checked for abstractness; deferring to runtime",
17041704
)
17051705
unverifiably_abstract.add(interface)
1706-
if _is_artificially_abstract(interface.form):
1706+
if isinstance(interface.form, IMeta) and _is_artificially_abstract(
1707+
interface.form
1708+
):
17071709
artificially_abstract.add(interface)
17081710
continue
17091711

@@ -1745,7 +1747,9 @@ def __deftype_and_reify_impls_are_all_abstract( # pylint: disable=too-many-loca
17451747
)
17461748

17471749
all_interface_methods.update(interface_names)
1748-
elif _is_artificially_abstract(interface.form):
1750+
elif isinstance(interface.form, IMeta) and _is_artificially_abstract(
1751+
interface.form
1752+
):
17491753
# Given that artificially abstract bases aren't real `abc.ABC`s and do
17501754
# not annotate their `abstractmethod`s, we can't assert right now that
17511755
# any the type will satisfy the artificially abstract base. However,
@@ -3197,7 +3201,7 @@ def _var_ast(form: ISeq, ctx: AnalyzerContext) -> VarRef:
31973201
raise ctx.AnalyzerException(f"cannot resolve var {var_sym}", form=form)
31983202

31993203
return VarRef(
3200-
form=var_sym,
3204+
form=form,
32013205
var=var,
32023206
return_var=True,
32033207
env=ctx.get_node_env(pos=ctx.syntax_position),

src/basilisp/lang/compiler/nodes.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
from basilisp.lang import set as lset
2222
from basilisp.lang import symbol as sym
2323
from basilisp.lang import vector as vec
24-
from basilisp.lang.interfaces import IPersistentMap, IPersistentSet, IPersistentVector
24+
from basilisp.lang.interfaces import (
25+
IPersistentMap,
26+
IPersistentSet,
27+
IPersistentVector,
28+
ISeq,
29+
)
2530
from basilisp.lang.runtime import Namespace, Var, to_lisp
2631
from basilisp.lang.typing import LispForm
2732
from basilisp.lang.typing import ReaderForm as ReaderLispForm
@@ -901,8 +906,8 @@ class Try(Node[SpecialForm]):
901906

902907

903908
@attr.frozen
904-
class VarRef(Node[sym.Symbol], Assignable):
905-
form: sym.Symbol
909+
class VarRef(Node[Union[sym.Symbol, ISeq]], Assignable):
910+
form: Union[sym.Symbol, ISeq]
906911
var: Var
907912
env: NodeEnv
908913
return_var: bool = False

0 commit comments

Comments
 (0)