Skip to content
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

Crystal::Macros::Arg#restriction method always returns Nop #14689

Open
mjblack opened this issue Jun 11, 2024 · 1 comment
Open

Crystal::Macros::Arg#restriction method always returns Nop #14689

mjblack opened this issue Jun 11, 2024 · 1 comment

Comments

@mjblack
Copy link

mjblack commented Jun 11, 2024

Bug Report

Crystal::Macros::Arg#restriction always returns Nop even if there is an ASTNode. I have tested this on Crystal version 1.12.2 on MacOS Sonoma. It was also tested by @Blacksmoke16 with Crystal master branch and the issue still exists.

The issue also exists for Crystal::Macros::FunDef#return_type.

lib MyLib
  type Int = LibC::Int

  fun foo(foo : LibC::Int) : Void
end

{% MyLib.methods.first.args.each { |t| pp t; pp t.restriction.class_name } %}
{% pp MyLib.methods.first.return_type.class_name %}
# => "foo"
# => "Nop"
# => "Nop"
@Blacksmoke16
Copy link
Member

I looked more into this the other day, and basically came to the conclusion that this is somewhat of expected behavior as part of #12848

Note: lib types won't be solved at the top-level because that happens later on. The reason for that is to not require forward declarations. But I think that even without resolved types this is useful.

As such this is more likely a feature request/enhancement than a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants