Comments (6)
#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.
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.
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.
%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.
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.
I agree, allowing Const
makes sense to me, even if it introduces the small ugliness.
from rubocop-ast.
Related Issues (20)
- rubocop-ast-0.4.0 has broken Layout/LineLength HOT 4
- Fix `traversal`
- Changelog link is a 404 HOT 3
- CI: check JRuby and other platforms
- Broken links in "Using Node Matcher Macros" documentation HOT 1
- Request: allow method calls on constants HOT 5
- `global_const?` and some other matchers should be available to cops
- Documentation for named `_` and backreferences in node pattern HOT 3
- Undefined method emit_forward_arg= in AST::Builder:Class HOT 3
- `ProcessedSource#ast_with_comments` doesn't differentiate between identical nodes HOT 4
- Issues with `parent_module_name`
- Missing files when attempting to do a gem build HOT 3
- `send_node.block_node` does not handle `numblock`s
- Long-shot parser -> lib-ruby-parser transition for performance boost? HOT 1
- Basic documentation of Node Pattern HOT 1
- Why is the live debugger not online anymore ? https://nodepattern.herokuapp.com/ HOT 4
- Do we need an MasgnNode ? HOT 2
- Experimental Prism feature listed as runtime dependency HOT 11
- Changelog for v1.31.2 is missing HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rubocop-ast.