Code Monkey home page Code Monkey logo

Comments (6)

dvandersluis avatar dvandersluis commented on May 27, 2024

#integer? works if only using numblocks, but will fail when mixed with regular blocks:

({block numblock} _recv {(args ...) #integer?})
#=> NoMethodError: undefined method `integer?' for ...

from rubocop-ast.

marcandre avatar marcandre commented on May 27, 2024

A precise example of what you are trying to achieve would help me.

You can use %Integer as a matcher, since Integer===(val) corresponds to val.is_a?(Integer)

from rubocop-ast.

marcandre avatar marcandre commented on May 27, 2024

You can also use is_a?(%Integer)

What is confusing is that Integer or int are both interpreted the same way currently, and are compiled to Integer_type? and int_type?. The former doesn't make much sense...

from rubocop-ast.

dvandersluis avatar dvandersluis commented on May 27, 2024

%Integer worked! Thanks!

This is the matcher, for rubocop#9127

def_node_matcher :symbol_proc?, <<~PATTERN
  ({block numblock}
    ${(send ...) (super ...) zsuper}
    ${(args (arg _)) %Integer}
    (send (lvar _var) $_))
PATTERN

from rubocop-ast.

marcandre avatar marcandre commented on May 27, 2024

Good. The question remains: should the % in front of the constant be necessary, and I'd be tempted to say no. OTOH the fact that Const or %Const would be the same is a bit ugly too...

from rubocop-ast.

dvandersluis avatar dvandersluis commented on May 27, 2024

I agree, allowing Const makes sense to me, even if it introduces the small ugliness.

from rubocop-ast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.