Граф коммитов

2118 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada b091889ed6 Removed YYUSE [Bug #17582]
Although it was used just to suppress an "unsed argument" warning
in the same manner as other bison-provided functions, it has been
dropped since Bision 3.7.5.  And we always suppress that
warnings.
2021-01-26 21:57:09 +09:00
Nobuyoshi Nakada 6bcc4664bd
Return new NODE_LIT
As NODE_ZLIST/NODE_LIST are not markable, cannot be reused as
NODE_LIT.
2021-01-14 16:15:25 +09:00
Nobuyoshi Nakada bb40c5cbe9
Ensure symbol list node is either NODE_STR or NODE_DSTR 2021-01-14 16:13:26 +09:00
Nobuyoshi Nakada 0036648a42
Capture to reserved name variables if already defined [Bug #17533] 2021-01-13 21:16:00 +09:00
Nobuhiro IMAI 7ff0e93f96
parse.y: handle "duplicated argument name" appropriately on ripper.y
refs: 733ed1e184
2021-01-09 13:33:33 +09:00
Nobuyoshi Nakada 35c3a24c8c
Fixed error message when % at EOF 2021-01-04 12:11:37 +09:00
Masataka Pocke Kuwabara de5f8a92d5
Make args info for RubyVM::AST to available on endless method without parens
Problem
===

Arguments information is missing for endless method without parens.
For example:

```ruby
# ok
pp RubyVM::AbstractSyntaxTree.parse(<<~RUBY).children[2]
  def x() = 42
RUBY
# => (DEFN@1:0-1:12
#     mid: :x
#     body:
#       (SCOPE@1:0-1:12
#        tbl: []
#        args:
#          (ARGS@1:5-1:6
#           pre_num: 0
#           pre_init: nil
#           opt: nil
#           first_post: nil
#           post_num: 0
#           post_init: nil
#           rest: nil
#           kw: nil
#           kwrest: nil
#           block: nil)
#        body: (LIT@1:10-1:12 42)))

# ok
pp RubyVM::AbstractSyntaxTree.parse(<<~RUBY).children[2]
  def x() 42 end
RUBY
# => (DEFN@1:0-1:14
#     mid: :x
#     body:
#       (SCOPE@1:0-1:14
#        tbl: []
#        args:
#          (ARGS@1:5-1:6
#           pre_num: 0
#           pre_init: nil
#           opt: nil
#           first_post: nil
#           post_num: 0
#           post_init: nil
#           rest: nil
#           kw: nil
#           kwrest: nil
#           block: nil)
#        body: (LIT@1:8-1:10 42)))

# It has a problem, the `args` is nil
pp RubyVM::AbstractSyntaxTree.parse(<<~RUBY).children[2]
  def x = 42
RUBY
# => (DEFN@1:0-1:10
#     mid: :x
#     body: (SCOPE@1:0-1:10 tbl: [] args: nil body: (LIT@1:8-1:10 42)))
```

It causes an error if a program expects `args` node exists.
For example: https://github.com/ruby/rbs/issues/551

Solution
====

Call `new_args` on this case.
2021-01-01 14:25:08 +09:00
Koichi Sasada 6f29716f9f shareable_constant_value: experimental_copy
"experimental_everything" makes the assigned value, it means
the assignment change the state of assigned value.
"experimental_copy" tries to make a deep copy and make copyied object
sharable.
2020-12-24 14:28:47 +09:00
Nobuyoshi Nakada 4a8ff22f0c
Reset paren_nest at tAREF and tASET [Bug #17431] 2020-12-24 01:39:52 +09:00
Nobuyoshi Nakada 8a1e12499b Ensure non-literal expressions shareable if `leteral` 2020-12-23 13:50:42 +09:00
Nobuyoshi Nakada 0c450b8647 `begin ... end` is not a literal 2020-12-23 13:50:42 +09:00
Nobuyoshi Nakada 7a094146e6 Changed shareable literal semantics [Feature #17397]
When `literal`, check if the literal about to be assigned to a
constant is ractor-shareable, otherwise raise `Ractor::Error` at
runtime instead of `SyntaxError`.
2020-12-23 13:50:42 +09:00
Nobuyoshi Nakada 733ed1e184 ripper: fix bad label parameter handling [Bug #17425] 2020-12-23 09:56:35 +09:00
Nobuyoshi Nakada b2acae3274
Reduced ID caches
NEW_GASGN and NEW_GVAR evaluate `id` argument twice.
2020-12-20 03:10:30 +09:00
Jeremy Evans 7e2dbbda35 Use category: :experimental in warnings that are related to experimental features
This adds rb_category_compile_warn in order to emit compiler warnings
with categories.  Note that Ripper currently ignores the category
for these warnings, but by default it ignores the warnings completely,
so this shouldn't matter.
2020-12-18 09:54:11 -08:00
Nobuyoshi Nakada 19a98a8791
Fixed not to make non-literal expression shareable [Feature #17273]
Non-literal expression which is not a part of a literal expression
is not a subject of `shareable_literal_value: literal`.
2020-12-19 00:34:14 +09:00
Nobuyoshi Nakada 8e03e3b0ba
Drop token info also for endless singleton method definition 2020-12-18 15:16:30 +09:00
Nobuyoshi Nakada 9c859f4b3c
Ripper: Pass callback result to alias_error as well as other errors
[Bug #17345]
2020-12-16 22:53:43 +09:00
Nobuyoshi Nakada 47328ad217
Ripper: Fixed erred token on wrong alias [Bug #17345] 2020-12-16 21:08:33 +09:00
Nobuyoshi Nakada e0bdd54348 Ripper: Refined error callbacks [Bug #17345] 2020-12-15 21:36:23 +09:00
Nobuyoshi Nakada 3323174727 Support shareable_constant_value: literal 2020-12-14 19:19:16 +09:00
Nobuyoshi Nakada 89e489d51d Make shareable_constant_value tri-state 2020-12-14 19:19:16 +09:00
Nobuyoshi Nakada 7060aeedbd shareable_constant_value: is effective only in comment-only line 2020-12-14 19:19:16 +09:00
Nobuyoshi Nakada 070a990bcb Save and pass lex_context wholely 2020-12-14 19:19:16 +09:00
Nobuyoshi Nakada dc1cc33d69 Determine shareable-ness after assignment operator 2020-12-14 19:19:16 +09:00
Nobuyoshi Nakada 60f0c376f7 Implemented shareable_constant_value op_asgn 2020-12-14 19:19:16 +09:00
Nobuyoshi Nakada 65450e8f7d Call FrozenCore.make_shareable 2020-12-14 19:19:16 +09:00
Nobuyoshi Nakada f43c71abe0 Implemented shareable_constant_value
It does shallow freeze only for now.
2020-12-14 19:19:16 +09:00
Nobuyoshi Nakada b1bd223085 Support shareable_constant_value pragma 2020-12-14 19:19:16 +09:00
Kazuki Tsujimoto 88f3ce12d3
Reintroduce `expr in pat` [Feature #17371] 2020-12-13 11:51:49 +09:00
Kazuki Tsujimoto a8cf526ae9
Don't emit warning when the pattern of one-line pattern matching is just a variable pattern
https://github.com/ruby/dev-meeting-log/blob/master/DevelopersMeeting20201210Japan.md#feature-17371-reintroduce-expr-in-pat-ktsj
2020-12-13 11:51:49 +09:00
Koichi Sasada 5e3259ea74 fix public interface
To make some kind of Ractor related extensions, some functions
should be exposed.

* include/ruby/thread_native.h
  * rb_native_mutex_*
  * rb_native_cond_*
* include/ruby/ractor.h
  * RB_OBJ_SHAREABLE_P(obj)
  * rb_ractor_shareable_p(obj)
  * rb_ractor_std*()
  * rb_cRactor

and rm ractor_pub.h
and rename srcdir/ractor.h to srcdir/ractor_core.h
    (to avoid conflict with include/ruby/ractor.h)
2020-11-18 03:52:41 +09:00
Jeremy Evans f5bb9115a7 Use more specific warning for ambiguous slash
Fixes [Bug #17124]
2020-11-15 15:25:32 -08:00
Nobuyoshi Nakada 79b242260b
ripper: Invalid pragma value warning 2020-11-02 22:49:42 +09:00
Nobuyoshi Nakada 539b89075a
Compare boolean values for parser pragma locale-insensitively 2020-11-02 18:24:45 +09:00
Kazuki Tsujimoto e03e1982bd
Change NODE layout for pattern matching
I prefer pconst to be the first element of NODE.

  Before:

       | ARYPTN | FNDPTN | HSHPTN
    ---+--------+--------+-----------
    u1 | imemo  | imemo  | pkwargs
    u2 | pconst | pconst | pconst
    u3 | apinfo | fpinfo | pkwrestarg

  After:

       | ARYPTN | FNDPTN | HSHPTN
    ---+--------+--------+-----------
    u1 | pconst | pconst | pconst
    u2 | imemo  | imemo  | pkwargs
    u3 | apinfo | fpinfo | pkwrestarg
2020-11-01 16:19:07 +09:00
Kazuki Tsujimoto b601532411
Pattern matching is no longer experimental 2020-11-01 13:33:58 +09:00
Nobuyoshi Nakada bdd1d17ac2
Allow non-argument endless-def with a space instead of parentheses 2020-10-26 21:15:16 +09:00
Nobuyoshi Nakada 52c630da00
Assoc pattern matching (#3703)
[Feature #17260] One-line pattern matching using tASSOC

R-assignment is rejected instead.
2020-10-26 18:00:24 +09:00
Nobuyoshi Nakada 4ed0c33d13
Prohibit setter method names in all kinds of endless methods
Also unwrap NODE_RIPPER to check the method name.
2020-10-12 00:40:55 +09:00
Nobuyoshi Nakada 8d1b188864
Refactored lex_context management
Save and restore `lex_context` as-is wholely, and save in
`k_class` and `k_module` to workaround look-ahead reading.
2020-10-09 13:44:48 +09:00
Nobuyoshi Nakada 7b2bea42a2
Unfreeze string-literal-only interpolated string-literal
[Feature #17104]
2020-09-30 22:15:28 +09:00
Koichi Sasada 79df14c04b Introduce Ractor mechanism for parallel execution
This commit introduces Ractor mechanism to run Ruby program in
parallel. See doc/ractor.md for more details about Ractor.
See ticket [Feature #17100] to see the implementation details
and discussions.

[Feature #17100]

This commit does not complete the implementation. You can find
many bugs on using Ractor. Also the specification will be changed
so that this feature is experimental. You will see a warning when
you make the first Ractor with `Ractor.new`.

I hope this feature can help programmers from thread-safety issues.
2020-09-03 21:11:06 +09:00
Nobuyoshi Nakada 93b78abd77
new_dstr: hoisted out from literal_concat and evstr2dstr 2020-09-02 13:30:16 +09:00
Yusuke Endoh 53ba9fb74e Prohibit setter method names in endless method definition
https://bugs.ruby-lang.org/issues/16746#note-26
2020-08-31 20:30:27 +09:00
Nobuyoshi Nakada 445e5548c9
Fixed error messages at non-ascii %string terminator 2020-08-26 21:36:22 +09:00
Nobuyoshi Nakada cc36b5d4ac
Removed a never-true condition 2020-08-26 21:16:51 +09:00
Kazuki Tsujimoto fcdbdff631
rb_{ary,fnd}_pattern_info: Remove imemo member to reduce memory usage
This is a partial revert commit of 8f096226e1.

NODE layout:

  Before:

       | ARYPTN | FNDPTN | HSHPTN
    ---+--------+--------+-----------
    u1 | pconst | pconst | pconst
    u2 | unused | unused | pkwargs
    u3 | apinfo | fpinfo | pkwrestarg

  After:

       | ARYPTN | FNDPTN | HSHPTN
    ---+--------+--------+-----------
    u1 | imemo  | imemo  | pkwargs
    u2 | pconst | pconst | pconst
    u3 | apinfo | fpinfo | pkwrestarg
2020-08-02 01:04:06 +09:00
Aaron Patterson 35ba2783fe Use a linked list to eliminate imemo tmp bufs for managing local tables
This patch changes local table memory to be managed by a linked list
rather than via the garbage collector.  It reduces allocations from the
GC and also fixes a use-after-free bug in the concurrent-with-sweep
compactor I'm working on.
2020-07-27 12:40:01 -07:00
Jeremy Evans d47e124857 Switch reserved for numbered parameter warning to SyntaxError 2020-07-22 08:34:51 -07:00