New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Semantic: fix to look up type var in macro called inside class #5349
Semantic: fix to look up type var in macro called inside class #5349
Conversation
@free_vars_cache = {} of GenericInstanceType => Hash(String, TypeVar) | ||
|
||
private def macro_free_vars_for_type(type) | ||
unless free_vars = @free_vars_cache[type]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use the following syntax?
@free_vars_cache[type] ||= begin
# build the value for this *type* here
end
This will get the value associated with type
, and if there is none, build the value and associate it with type
in the hash, and return it.
ab95e27
to
1e846c9
Compare
Hmm now we have a (maybe?) unwanted behavior: class Foo(T)
macro foo(node)
{{node.resolve}}
end
end
alias FooInt32 = Foo(Int32)
class Bar
def self.foo
FooInt32.foo T
end
end
p Bar.foo # => Int32 What I want to hightlight here is that in Maybe it's not an issue after all, but this is definitely not documented, and is unexpected for a |
I think this can be closed in favor of #5354. |
@makenowjust what is the status of this PR? |
#5354 has been merged, we can close this pr now |
@bew Yes. I'll close. |
Fixed #5343