opal 1.1.1 → 1.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +3 -2
  3. data/.github/ISSUE_TEMPLATE/bug-report.md +47 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. data/.github/workflows/build.yml +11 -5
  6. data/.gitignore +1 -0
  7. data/.jshintrc +1 -1
  8. data/Gemfile +0 -4
  9. data/HACKING.md +1 -1
  10. data/README.md +19 -15
  11. data/UNRELEASED.md +41 -0
  12. data/benchmark-ips/bm_array_unshift.rb +7 -0
  13. data/bin/opal-mspec +2 -0
  14. data/docs/compiler.md +1 -1
  15. data/examples/rack/Gemfile +0 -1
  16. data/examples/rack/Gemfile.lock +0 -4
  17. data/lib/opal/cli.rb +1 -0
  18. data/lib/opal/cli_options.rb +4 -0
  19. data/lib/opal/cli_runners/nodejs.rb +4 -0
  20. data/lib/opal/cli_runners/source-map-support-browser.js +3 -1
  21. data/lib/opal/cli_runners/source-map-support-node.js +3 -1
  22. data/lib/opal/cli_runners/source-map-support.js +3 -1
  23. data/lib/opal/compiler.rb +2 -2
  24. data/lib/opal/nodes/args/arity_check.rb +1 -0
  25. data/lib/opal/nodes/args/parameters.rb +6 -0
  26. data/lib/opal/nodes/class.rb +1 -13
  27. data/lib/opal/nodes/literal.rb +14 -7
  28. data/lib/opal/nodes/module.rb +13 -9
  29. data/lib/opal/nodes/variables.rb +13 -4
  30. data/lib/opal/nodes/while.rb +54 -17
  31. data/lib/opal/parser.rb +1 -5
  32. data/lib/opal/parser/patch.rb +34 -0
  33. data/lib/opal/repl.rb +7 -0
  34. data/lib/opal/rewriter.rb +2 -0
  35. data/lib/opal/rewriters/arguments.rb +4 -1
  36. data/lib/opal/rewriters/forward_args.rb +54 -0
  37. data/lib/opal/rewriters/logical_operator_assignment.rb +5 -2
  38. data/lib/opal/rewriters/opal_engine_check.rb +5 -7
  39. data/lib/opal/version.rb +1 -1
  40. data/opal/corelib/array.rb +42 -20
  41. data/opal/corelib/array/pack.rb +6 -1
  42. data/opal/corelib/complex.rb +2 -0
  43. data/opal/corelib/constants.rb +3 -3
  44. data/opal/corelib/hash.rb +36 -38
  45. data/opal/corelib/module.rb +2 -7
  46. data/opal/corelib/number.rb +2 -180
  47. data/opal/corelib/numeric.rb +156 -0
  48. data/opal/corelib/object_space.rb +102 -0
  49. data/opal/corelib/random.rb +31 -66
  50. data/opal/corelib/random/formatter.rb +122 -0
  51. data/opal/corelib/range.rb +50 -19
  52. data/opal/corelib/runtime.js +82 -21
  53. data/opal/corelib/string.rb +86 -52
  54. data/opal/corelib/string/encoding.rb +140 -25
  55. data/opal/corelib/string/unpack.rb +26 -40
  56. data/opal/opal.rb +1 -0
  57. data/opal/opal/full.rb +1 -0
  58. data/spec/filters/bugs/array.rb +0 -22
  59. data/spec/filters/bugs/basicobject.rb +3 -0
  60. data/spec/filters/bugs/encoding.rb +0 -2
  61. data/spec/filters/bugs/exception.rb +1 -0
  62. data/spec/filters/bugs/float.rb +0 -2
  63. data/spec/filters/bugs/hash.rb +2 -7
  64. data/spec/filters/bugs/integer.rb +0 -2
  65. data/spec/filters/bugs/kernel.rb +16 -3
  66. data/spec/filters/bugs/language.rb +6 -14
  67. data/spec/filters/bugs/marshal.rb +1 -3
  68. data/spec/filters/bugs/module.rb +16 -1
  69. data/spec/filters/bugs/numeric.rb +4 -12
  70. data/spec/filters/bugs/objectspace.rb +67 -0
  71. data/spec/filters/bugs/pack_unpack.rb +0 -9
  72. data/spec/filters/bugs/pathname.rb +1 -0
  73. data/spec/filters/bugs/proc.rb +8 -0
  74. data/spec/filters/bugs/random.rb +3 -6
  75. data/spec/filters/bugs/range.rb +83 -113
  76. data/spec/filters/bugs/set.rb +2 -0
  77. data/spec/filters/bugs/string.rb +31 -70
  78. data/spec/filters/bugs/struct.rb +2 -0
  79. data/spec/filters/bugs/time.rb +8 -2
  80. data/spec/filters/unsupported/float.rb +3 -0
  81. data/spec/filters/unsupported/freeze.rb +1 -0
  82. data/spec/filters/unsupported/integer.rb +3 -0
  83. data/spec/filters/unsupported/refinements.rb +5 -0
  84. data/spec/filters/unsupported/string.rb +100 -95
  85. data/spec/filters/unsupported/time.rb +4 -0
  86. data/spec/lib/compiler_spec.rb +16 -0
  87. data/spec/lib/rewriters/forward_args_spec.rb +61 -0
  88. data/spec/lib/rewriters/logical_operator_assignment_spec.rb +1 -1
  89. data/spec/lib/rewriters/numblocks_spec.rb +44 -0
  90. data/spec/lib/rewriters/opal_engine_check_spec.rb +49 -4
  91. data/spec/opal/core/language/forward_args_spec.rb +53 -0
  92. data/spec/opal/core/language/infinite_range_spec.rb +13 -0
  93. data/spec/opal/core/language/memoization_spec.rb +16 -0
  94. data/spec/opal/core/module_spec.rb +38 -2
  95. data/spec/opal/core/number/to_i_spec.rb +28 -0
  96. data/spec/opal/core/runtime/bridged_classes_spec.rb +16 -0
  97. data/spec/opal/core/runtime/constants_spec.rb +20 -1
  98. data/spec/opal/core/string/subclassing_spec.rb +16 -0
  99. data/spec/opal/core/string/unpack_spec.rb +22 -0
  100. data/spec/opal/core/string_spec.rb +4 -4
  101. data/spec/ruby_specs +4 -1
  102. data/stdlib/json.rb +3 -1
  103. data/stdlib/securerandom.rb +55 -35
  104. data/tasks/testing.rake +6 -3
  105. data/test/nodejs/test_string.rb +25 -0
  106. data/vendored-minitest/minitest/assertions.rb +2 -0
  107. metadata +31 -10
  108. data/lib/opal/parser/with_c_lexer.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac8b5ed5a8d6ca758a11a21e74a5f2d04f97e90dfdd0e5a6a95322c44cc22c38
4
- data.tar.gz: 85a1a6c74a8a25628f56a72ad1731692fb0e02a969712bf0f44cf3bc9f643c22
3
+ metadata.gz: 2a574a86358acd4f97b91deecaa9395068503a2198c6a8b646ee5b9df35a8d5c
4
+ data.tar.gz: 800255837fc95ecbfa4268c4a4b21df99ad1fb427fe4b90a5100bbed75833791
5
5
  SHA512:
6
- metadata.gz: 0a60db99a26bd216ef138b5b085d9da2ee2a741a870c4bd524445fef3e0d16ad28cf4e0d485c16113da022d35fda782849ccfe5c604a01f99e55ff14045daa86
7
- data.tar.gz: b068c7a82210a814f8c6a9420823a3aaa16834e25028ef179172570435e26858dcce888e2a4d0e80a611e08e2654facaa5a7bb0c2f829773eea3e917d0447456
6
+ metadata.gz: 471561bdda1f595110d95be228b6caad444b0064e84b13d37c250c70b1e505e897c6f9f69c93afa11b13a268b98acef4d62508ba19ac1304d3c5d8178563b10f
7
+ data.tar.gz: 4620c4fc0ee08df1840300b1b03fe3cedabee19dc22c986b7151538b211da69046c4b164c8bd4145c16e4d54307376314a4514b9b95fb540fc0e37fdb8671511
data/.codeclimate.yml CHANGED
@@ -9,13 +9,13 @@ checks:
9
9
  threshold: 10
10
10
  file-lines:
11
11
  config:
12
- threshold: 250
12
+ threshold: 1000
13
13
  method-complexity:
14
14
  config:
15
15
  threshold: 5
16
16
  method-count:
17
17
  config:
18
- threshold: 20
18
+ threshold: 100
19
19
  method-lines:
20
20
  config:
21
21
  threshold: 30
@@ -39,6 +39,7 @@ plugins:
39
39
 
40
40
  exclude_patterns:
41
41
  - "benchmark/*"
42
+ - "benchmark-ips/*"
42
43
  - "build/*"
43
44
  - "coverage/*"
44
45
  - "docs/*"
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: 'Bug: '
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ <!-- A clear and concise description of what the bug is.
12
+ Please clarify if it's a missing feature. -->
13
+
14
+ Opal version: …
15
+
16
+
17
+ **To Reproduce**
18
+
19
+ <!--
20
+ Steps to reproduce the behavior.
21
+
22
+ You can contrasting it to Ruby's behavior:
23
+
24
+ ```
25
+ $ opal -v -e "puts 123"
26
+ 123
27
+ ```
28
+
29
+ ```
30
+ $ruby -v -e "puts 123"
31
+ ```
32
+
33
+ or show an error in the compiled code:
34
+
35
+ ```
36
+ $ opal -v -e "puts 123" -cEO
37
+
38
+ /* Generated by Opal 1.1.1 */
39
+ (function(Opal) {
40
+ var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$, $$ = Opal.$$;
41
+
42
+ Opal.add_stubs(['$puts']);
43
+ return self.$puts(123)
44
+ })(Opal);
45
+
46
+ ```
47
+ -->
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: 'Feature: '
5
+ labels: feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -6,9 +6,7 @@ on:
6
6
  - master
7
7
  - "*-stable"
8
8
  - "*/ci-check"
9
- pull_request:
10
- branches:
11
- - master
9
+ pull_request: {}
12
10
 
13
11
  jobs:
14
12
  rake:
@@ -26,14 +24,18 @@ jobs:
26
24
  - name: minitest
27
25
  ruby: 3.0
28
26
  command: bin/rake minitest
27
+ - name: minitest-strict-mode
28
+ ruby: 3.0
29
+ command: bin/rake minitest
30
+ strict: 'true'
29
31
  - name: current-ruby
30
32
  ruby: 3.0
31
33
  - name: previous-ruby
32
34
  ruby: 2.7
33
35
  - name: older-ruby
34
36
  ruby: 2.6
35
- - name: near-eol-ruby
36
- ruby: 2.5
37
+ # - name: near-eol-ruby
38
+ # ruby: 2.6
37
39
  - name: smoke-test
38
40
  ruby: 3.0
39
41
  command: bin/rake smoke_test
@@ -87,4 +89,8 @@ jobs:
87
89
  bundle config path $PWD/vendor/bundle
88
90
  bundle install --jobs 4 --retry 3
89
91
  bundle clean
92
+ - name: set environment variables
93
+ if: ${{ matrix.combo.strict == 'true' }}
94
+ run: |
95
+ echo "USE_STRICT=true" >> $GITHUB_ENV
90
96
  - run: ${{ matrix.combo.command || 'bin/rake rspec' }}
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .yardoc
4
4
  .bundle
5
5
  Gemfile.lock
6
+ Gemfile.local
6
7
  build/
7
8
  /.github_access_token
8
9
  /cdn
data/.jshintrc CHANGED
@@ -10,7 +10,7 @@
10
10
  "undef" : true, // Prohibit the use of explicitly undeclared variables
11
11
  "unused" : true, // Warn when you define and never use your variables
12
12
 
13
- "predef" : ["Opal", "JSON", "Java", "OpalNode", "jsyaml", "globalThis"],
13
+ "predef" : ["Opal", "JSON", "Java", "OpalNode", "jsyaml", "globalThis", "FinalizationRegistry", "WeakMap"],
14
14
 
15
15
  "browser": true,
16
16
  "node": true,
data/Gemfile CHANGED
@@ -48,7 +48,3 @@ end unless ENV['CI']
48
48
  group :doc do
49
49
  gem 'redcarpet' unless RUBY_ENGINE == 'truffleruby'
50
50
  end unless ENV['CI']
51
-
52
- platforms :ruby, :mswin, :mswin64, :mingw, :x64_mingw do
53
- #gem 'c_lexer', '~> 2.6' unless RUBY_ENGINE == 'truffleruby'
54
- end
data/HACKING.md CHANGED
@@ -33,7 +33,7 @@ Before making changes to Opal source, you need to understand a little about how
33
33
 
34
34
  Navigating to `spec/ruby/core` directory, you see that it contains multiple sub-directories, usually named after the Ruby class or module. Drilling further down into `spec/ruby/core/string` you see all the spec files for the various `String` behaviors under test, usually named by a method name followed by `_spec.rb`. Opening `spec/ruby/core/string/sub_spec.rb` you finally see the code that checks the correctness of Opal's implementation of the `String#sub` method's behavior.
35
35
 
36
- When you execute `$ bundle exec rake`, the code in this file is executed, along with all the other specs in the entire test suite. It's a good idea to run the entire test suite when you feel you reached a certain milestone in the course of making your changes (exactly what that means is up to you), and definitely do `$ bundle exec rake` before commiting your changes to make sure they have not introduced regressions or other unintended side effects.
36
+ When you execute `$ bundle exec rake`, the code in this file is executed, along with all the other specs in the entire test suite. It's a good idea to run the entire test suite when you feel you reached a certain milestone in the course of making your changes (exactly what that means is up to you), and definitely do `$ bundle exec rake` before committing your changes to make sure they have not introduced regressions or other unintended side effects.
37
37
 
38
38
  But you will want to run tests as often as possible, after every small change, and running the entire test suite will slow you down. You need to be able to execute a single spec that is concerned with the feature you are currently working on. To accomplish this, just add `PATTERN` to your spec invocation command, like this:
39
39
 
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  align="center" title="Opal logo by Elia Schito" width="105" height="105" />
4
4
  <br/>
5
5
  Opal <br/>
6
- <img src="https://img.shields.io/badge/Opal-Ruby%20💛%20JavaScript-yellow.svg?logo=ruby&style=social&logoColor=777"/>
6
+ <img src="https://img.shields.io/badge/Opal-Ruby%20💛%20JavaScript-yellow.svg?logo=ruby&style=social&logoColor=777" alt="Opal-Ruby 💛 JavaScript"/>
7
7
  </h1>
8
8
 
9
9
  <p align="center">
@@ -16,19 +16,19 @@
16
16
  <a href="https://stackoverflow.com/questions/ask?tags=opalrb"><img src="https://img.shields.io/badge/stackoverflow-%23opalrb-orange.svg?style=flat" alt="Stack Overflow" title="" /></a>
17
17
  <a href="#backers"><img src="https://opencollective.com/opal/backers/badge.svg" alt="Backers on Open Collective" title="" /></a>
18
18
  <a href="#sponsors"><img src="https://opencollective.com/opal/sponsors/badge.svg" alt="Sponsors on Open Collective" title="" /></a>
19
- <a href="https://gitter.im/opal/opal?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Gitter" title="" /></a>
19
+ <a href="https://slack.opalrb.com/"><img src="https://img.shields.io/badge/slack-join%20chat-46BC99?logo=slack&style=flat" alt="Slack" title="Join Chat" /></a>
20
20
  <a href="https://opalrb.com/docs"><img src="https://img.shields.io/badge/docs-updated-blue.svg" alt="Documentation" title="" /></a>
21
21
 
22
22
  <br>
23
23
  <strong>Code:</strong><br>
24
24
  <a href="https://badge.fury.io/rb/opal"><img src="https://img.shields.io/gem/v/opal.svg?style=flat" alt="Gem Version" title="" /></a>
25
- <a href="https://github.com/opal/opal/actions?query=workflow%3Abuild"><img alt="Build Status" src="https://github.com/opal/opal/workflows/build/badge.svg" /></a>
25
+ <a href="https://github.com/opal/opal/actions?query=workflow%3Abuild"><img src="https://github.com/opal/opal/workflows/build/badge.svg" alt="Build Status" /></a>
26
26
  <a href="https://codeclimate.com/github/opal/opal"><img src="https://img.shields.io/codeclimate/maintainability-percentage/opal/opal.svg" alt="Code Climate" title="" /></a>
27
27
  <a href="https://coveralls.io/github/opal/opal?branch=master"><img src="https://coveralls.io/repos/opal/opal/badge.svg?branch=master&amp;service=github" alt="Coverage Status" title="" /></a>
28
28
 
29
29
  <br>
30
30
  <strong>Sponsors:</strong>
31
- <br/><a href="https://nebulab.it?utm_source=github&utm_medium=badge"><img src="https://img.shields.io/static/v1?label=Nebulab&message=Open+Source+Fridays&color=%235dbefd&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMQSURBVHgBrZZNTxNRFIbfczsgIMQiLBCRFDaGhUr9A9iiIa5EEneIwE/AlRsNv8KlIKwFl35RTUBX8rFBdiVKAgqmXSCY0M71nJl+zJTOdKh9k6Yzc8/cZ86555x7CQE0mji5hSyGlQoNaOgIPwrnhtIArWszu4EQFudjdR8rzUV+gw8/ZMZB9IwvIwimJJGafhmjWZwFOJ7QkYzWCwTdj+qUDJGKz8Rou3RAlT4YS+hHWW2u/QdM1MNzrI6+zwyXDrg8FANStIDaSXOIJ5whLgAljOIZiglRK6U4vDfz4S2ElGGJWsEaQkCTUbhtNbV+lb+xgFY2Bs9ET0h/GzBxlfAkqnCUKY5xKfVLbsi1/R126lcF6WgCYp2ES42EBp6tvQFY+alLTUlrUxizJEVNWiVwBkVagGg7oe+CDclLYOfrgMdfTBz8PfWa1lkzbsDEsH/5FyF9YUK0zQ1xwpoZtsm9pwxMRLyA9wyi0A2Jcjl1NNqeeEFEimxYPkmWd014ikIDnDTeBb53DOweaRxnvWGyhnmYfPZWGt487sNi6lsK67/lZ1oZGOtUaD3nhtU7etXXfe0VzrzCBgLKCR68rNDX6oaJlvd0xXnklbSfgSTL/QghXF8EP980cVKyVL/Ys9UDVFJa8Tdt+1lYmcmJM3Vd4UEvWeslRf32h9ubrVRl77gBrCto85OfUU+LXTMGx+JuN2Hoin3/Zkfjj6ObBAknV+KG4jpc9BqXMEpiCMz6Z9ZQ12kvJZxb6co4Zr1W83esY8F2OYsIe+eEyfTiVXczCl7uM2wliHfMEJaRc3Wa++mLUotrF4EW7h6f94Dvh6aVFM60Fy8Xkya+BfBOjh5yUWhqY0vmKi9q1GnVxZ7sHKIWSs7FQ71yUagkRTTCfymnVY1gsgHHC5z8hbUjaz0Fr8ZanXhX0pPOw5SrV8wNGjNscMrTKpXKaj05f9twVYHnMZGPHEuwTwEBNi+3NGiNt6GRcsfEIAfhp2cAV3cQLtXoOz7q8+ZJRLx3kmxn4dy7aas1SrfiBpKraV/9A+PSJLDAXLUvAAAAAElFTkSuQmCC"></a>
31
+ <br/><a href="https://nebulab.it?utm_source=github&utm_medium=badge"><img src="https://img.shields.io/static/v1?label=Nebulab&message=Open+Source+Fridays&color=%235dbefd&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMQSURBVHgBrZZNTxNRFIbfczsgIMQiLBCRFDaGhUr9A9iiIa5EEneIwE/AlRsNv8KlIKwFl35RTUBX8rFBdiVKAgqmXSCY0M71nJl+zJTOdKh9k6Yzc8/cZ86555x7CQE0mji5hSyGlQoNaOgIPwrnhtIArWszu4EQFudjdR8rzUV+gw8/ZMZB9IwvIwimJJGafhmjWZwFOJ7QkYzWCwTdj+qUDJGKz8Rou3RAlT4YS+hHWW2u/QdM1MNzrI6+zwyXDrg8FANStIDaSXOIJ5whLgAljOIZiglRK6U4vDfz4S2ElGGJWsEaQkCTUbhtNbV+lb+xgFY2Bs9ET0h/GzBxlfAkqnCUKY5xKfVLbsi1/R126lcF6WgCYp2ES42EBp6tvQFY+alLTUlrUxizJEVNWiVwBkVagGg7oe+CDclLYOfrgMdfTBz8PfWa1lkzbsDEsH/5FyF9YUK0zQ1xwpoZtsm9pwxMRLyA9wyi0A2Jcjl1NNqeeEFEimxYPkmWd014ikIDnDTeBb53DOweaRxnvWGyhnmYfPZWGt487sNi6lsK67/lZ1oZGOtUaD3nhtU7etXXfe0VzrzCBgLKCR68rNDX6oaJlvd0xXnklbSfgSTL/QghXF8EP980cVKyVL/Ys9UDVFJa8Tdt+1lYmcmJM3Vd4UEvWeslRf32h9ubrVRl77gBrCto85OfUU+LXTMGx+JuN2Hoin3/Zkfjj6ObBAknV+KG4jpc9BqXMEpiCMz6Z9ZQ12kvJZxb6co4Zr1W83esY8F2OYsIe+eEyfTiVXczCl7uM2wliHfMEJaRc3Wa++mLUotrF4EW7h6f94Dvh6aVFM60Fy8Xkya+BfBOjh5yUWhqY0vmKi9q1GnVxZ7sHKIWSs7FQ71yUagkRTTCfymnVY1gsgHHC5z8hbUjaz0Fr8ZanXhX0pPOw5SrV8wNGjNscMrTKpXKaj05f9twVYHnMZGPHEuwTwEBNi+3NGiNt6GRcsfEIAfhp2cAV3cQLtXoOz7q8+ZJRLx3kmxn4dy7aas1SrfiBpKraV/9A+PSJLDAXLUvAAAAAElFTkSuQmCC" alt="Nebulab: Open Source Fridays" /></a>
32
32
  </p>
33
33
 
34
34
  ## Usage
@@ -216,21 +216,16 @@ then we support Opera 12.1x, 19.x and 20.x but not Opera 15.x through 18.x.
216
216
 
217
217
  This project exists thanks to all the people who contribute. [![contributors](https://opencollective.com/opal/contributors.svg?width=890&button=false")](https://github.com/opal/opal/graphs/contributors)
218
218
 
219
+ ## Versioning
220
+
221
+ Opal will broadly follow semver as a version policy, trying to bump the major version when introducing breaking changes.
222
+ Being a language implementation we're also aware that there's a fine line between what can be considered breaking and what is expected to be "safe" or just "additive". Moving forward we'll attempt to better clarify what interfaces are meant to be public and what should be considered private.
219
223
 
220
224
  ## Backers
221
225
 
222
226
  Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/opal#backer)]
223
227
 
224
- <a href="https://opencollective.com/opal#backers" target="_blank"><img src="https://opencollective.com/opal/backers.svg?width=890"></a>
225
-
226
-
227
- ## Sponsors
228
-
229
- ### Donations
230
-
231
- Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/opal#sponsor)]
232
-
233
- <a href="https://opencollective.com/opal/sponsor/0/website" target="_blank"><img src="https://opencollective.com/opal/sponsor/0/avatar.svg"></a>
228
+ <a href="https://opencollective.com/opal#backers" target="_blank"><img src="https://opencollective.com/opal/backers.svg?width=890" alt="Become a Backer Button" /></a>
234
229
  <a href="https://opencollective.com/opal/sponsor/1/website" target="_blank"><img src="https://opencollective.com/opal/sponsor/1/avatar.svg"></a>
235
230
  <a href="https://opencollective.com/opal/sponsor/2/website" target="_blank"><img src="https://opencollective.com/opal/sponsor/2/avatar.svg"></a>
236
231
  <a href="https://opencollective.com/opal/sponsor/3/website" target="_blank"><img src="https://opencollective.com/opal/sponsor/3/avatar.svg"></a>
@@ -241,9 +236,18 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
241
236
  <a href="https://opencollective.com/opal/sponsor/8/website" target="_blank"><img src="https://opencollective.com/opal/sponsor/8/avatar.svg"></a>
242
237
  <a href="https://opencollective.com/opal/sponsor/9/website" target="_blank"><img src="https://opencollective.com/opal/sponsor/9/avatar.svg"></a>
243
238
 
239
+
240
+ ## Sponsors
241
+
242
+ ### Donations
243
+
244
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/opal#sponsor)]
245
+
246
+ <a href="https://opencollective.com/opal/sponsor/0/website" target="_blank"><img src="https://opencollective.com/opal/sponsor/0/avatar.svg" alt="Become a Sponsor Button"></a>
247
+
244
248
  ### Sponsored Contributions
245
249
 
246
- <a href="https://nebulab.it/?utm_source=github&utm_medium=sponsors" target="_blank"><img src="https://nebulab.it/assets/images/logo-586625a4.svg"></a>
250
+ <a href="https://nebulab.it/?utm_source=github&utm_medium=sponsors" target="_blank"><img src="https://nebulab.com/assets/img/logo-nebulab_black.svg" alt="Nebulab Logo"></a>
247
251
 
248
252
 
249
253
  ## License
data/UNRELEASED.md CHANGED
@@ -1,5 +1,46 @@
1
1
  ### Added
2
+
3
+ - Support for multiple arguments in Hash#{merge, merge!, update} (#2187)
4
+ - Support for Ruby 3.0 forward arguments: `def a(...) puts(...) end` (#2153)
5
+ - Support for beginless and endless ranges: `(1..)`, `(..1)` (#2150)
6
+ - Preliminary support for `**nil` argument - see #2240 to note limitations (#2152)
7
+ - Support for `Random::Formatters` which add methods `#{hex,base64,urlsafe_base64,uuid,random_float,random_number,alphanumeric}` to `Random` and `SecureRandom` (#2218)
8
+ - Basic support for ObjectSpace finalizers and ObjectSpace::WeakMap (#2247)
9
+ - A more robust support for encodings (especially binary strings) (#2235)
10
+ - Support for `"\x80"` syntax in String literals (#2235)
11
+ - Added `String#+@`, `String#-@` (#2235)
12
+ - Support for `begin <CODE> end while <CONDITION>` (#2255)
13
+
2
14
  ### Fixed
15
+
16
+ - Encoding lookup was working only with uppercase names, not giving any errors for wrong ones (#2181, #2183, #2190)
17
+ - Fix `Number#to_i` with huge number (#2191)
18
+ - Add regexp support to `String#start_with` (#2198)
19
+ - `String#bytes` now works in strict mode (#2194)
20
+ - Fix nested module inclusion (#2053)
21
+ - SecureRandom is now cryptographically secure on most platforms (#2218, #2170)
22
+ - Fix performance regression for `Array#unshift` on v8 > 7.1 (#2116)
23
+ - String subclasses now call `#initialize` with multiple arguments correctly (with a limitation caused by the String immutability issue, that a source string must be the first argument and `#initialize` can't change its value) (#2238, #2185)
24
+ - Number#step is moved to Numeric (#2100)
25
+ - Fix class Class < superclass for invalid superclasses (#2123)
26
+ - Fix `String#unpack("U*")` on binary strings with latin1 high characters, fix performance regression on that call (#2235, #2189, #2129, #2099, #2094, #2000, #2128)
27
+ - Fix `String#to_json` output on some edge cases (#2235)
28
+ - Rework class variables to support inheritance correctly (#2251)
29
+ - ISO-8859-1 and US-ASCII encodings are now separated as in MRI (#2235)
30
+ - `String#b` no longer modifies object strings in-place (#2235)
31
+
3
32
  ### Changed
33
+
34
+ - `String#unpack`, `Array#pack`, `String#chars`, `String#length`, `Number#chr`, and (only partially) `String#+` are now encoding aware (#2235)
35
+ - `String#inspect` now uses `\x` for binary stirngs (#2235)
36
+ - `if RUBY_ENGINE == "opal"` and friends are now outputing less JS code (#2159, #1965)
37
+ - `Array`: `to_a`, `slice`/`[]`, `uniq`, `*`, `difference`/`-`, `intersection`/`&`, `union`/`|`, flatten now return Array, not a subclass, as Ruby 3.0 does (#2237)
38
+ - `Array`: `difference`, `intersection`, `union` now accept multiple arguments (#2237)
39
+
4
40
  ### Deprecated
41
+
42
+ - Stopped testing Opal on Ruby 2.5 since it reached EOL.
43
+
5
44
  ### Removed
45
+
46
+ - Removed support for the outdated `c_lexer`, it was optional and didn't work for the last few releases of parser (#2235)
@@ -0,0 +1,7 @@
1
+ Benchmark.ips do |x|
2
+ x.report("unshift") do
3
+ a = ['4768', '4964', '4266', '4872', '4231', '4017', '4565', '4793', '4298', '4135', '4639', '4780', '4237', '4548', '4655', '4153', '4654', '4922', '4563', '4042', '4329', '4699', '4352', '4127', '4544', '4906', '4814', '4948', '4977', '4830', '4405', '4642', '4666', '4402', '4679', '4465', '4401', '4155', '4767', '4510', '4747', '4993', '4508', '4697', '4758', '4133', '4348', '4200', '4442', '4970', '4452', '4041', '4103', '4567', '4937', '4047', '4933', '4121', '4860', '4659', '4221', '4312', '4583', '4473', '4973', '4262', '4630', '4123', '4139', '4289', '4147', '4222', '4050', '4019', '4454', '4253', '4552', '4947', '4725', '4457', '4929', '4021', '4502', '4307', '4576', '4124', '4586', '4610', '4027', '4572', '4926', '4753', '4185', '4382', '4394', '4923', '4186', '4254', '4012', '4417', '4556', '4349', '4550', '4330', '4938', '4985', '4778', '4716', '4924', '4045', '4358', '4189', '4591', '4213', '4851', '4825', '4260', '4198', '4342', '4824', '4333', '4244', '4752', '4994', '4488', '4532', '4082', '4595', '4098', '4436', '4540', '4267', '4407', '4998', '4751', '4535', '4861', '4819', '4419', '4031', '4029', '4453', '4698', '4965', '4450', '4668', '4036', '4300', '4519', '4281', '4981', '4818', '4939', '4378', '4140', '4841', '4249', '4290', '4388', '4878', '4884', '4235', '4515', '4638', '4410', '4054', '4383', '4238', '4870', '4295', '4804', '4308', '4614', '4105', '4053', '4446', '4757', '4971', '4637', '4831', '4193', '4912', '4000', '4187', '4606', '4566', '4169', '4641', '4749', '4729', '4928', '4601', '4949', '4210', '4313', '4647', '4495', '4460', '4621', '4605', '4694', '4317', '4226', '4263', '4016', '4997', '4940', '4715', '4907', '4620', '4934', '4996', '4955', '4688', '4304', '4220', '4882', '4772', '4536', '4815', '4693', '4469', '4276', '4409', '4071', '4224', '4020', '4629', '4865', '4813', '4366', '4622', '4129', '4533', '4634', '4564', '4087', '4386', '4161', '4265', '4711', '4009', '4376', '4781', '4837', '4112', '4915', '4592', '4658', '4025', '4987', '4291', '4477', '4503', '4437', '4111', '4707', '4879', '4611', '4549', '4078', '4044', '4853', '4835', '4463', '4577', '4008', '4233', '4741', '4384', '4225', '4024', '4726', '4743', '4160', '4180', '4722', '4609', '4114', '4834', '4742', '4662', '4984', '4299', '4060', '4498', '4755', '4320', '4874', '4528', '4216', '4852', '4951', '4958', '4283', '4239', '4476', '4644', '4143', '4104', '4455', '4126', '4950', '4663', '4013', '4931', '4850', '4242', '4130', '4623', '4871', '4014', '4854', '4293', '4512', '4166', '4740', '4735', '4150', '4651', '4172', '4836', '4530', '4664', '4429', '4511', '4558', '4676', '4085', '4074', '4580', '4794', '4379', '4310', '4817', '4966', '4848', '4202', '4336', '4608', '4351', '4396', '4652', '4033', '4188', '4431', '4916', '4259', '4607', '4816', '4810', '4627', '4527', '4560', '4728', '4589', '4274', '4809', '4790', '4398', '4414', '4516', '4581', '4919', '4665', '4331', '4978', '4543', '4877', '4974', '4284', '4004', '4177', '4466', '4116', '4217', '4901', '4372', '4137', '4806', '4264', '4497', '4294', '4787', '4212', '4215', '4115', '4782', '4739', '4821', '4125', '4505', '4230', '4399', '4395', '4079', '4867', '4381', '4706', '4695', '4404', '4691', '4075', '4353', '4301', '4876', '4731', '4523', '4246', '4529', '4412', '4784', '4449', '4229', '4616', '4158', '4002', '4318', '4377', '4205', '4911', '4777', '4792', '4271', '4763', '4141', '4287', '4890', '4279', '4829', '4646', '4840', '4089', '4880', '4067', '4918', '4059', '4109', '4164', '4863', '4883', '4909', '4361', '4174', '4960', '4302', '4003', '4236', '4846', '4034', '4324', '4513', '4765', '4596', '4900', '4007', '4603', '4474', '4439', '4805', '4015', '4496', '4953', '4363', '4551', '4459', '4063', '4983', '4881', '4365', '4604', '4587', '4798', '4005', '4163', '4421', '4471', '4826', '4144', '4635', '4600', '4913', '4640', '4247', '4766', '4779', '4280', '4391', '4891', '4636', '4546', '4683', '4181', '4081', '4862', '4458', '4037', '4321', '4786', '4717', '4628', '4154', '4326', '4032', '4873', '4151', '4905', '4270', '4156', '4733', '4980', '4866', '4325', '4055', '4467', '4480', '4286', '4191', '4762', '4322', '4574', '4022', '4056', '4770', '4451', '4448', '4845', '4341', '4433', '4245', '4684', '4671', '4093', '4920', '4272', '4745', '4799', '4761', '4250', '4578', '4347', '4499', '4526', '4369', '4162', '4537', '4434', '4893', '4120', '4962', '4667', '4525', '4091', '4462', '4182', '4738', '4935', '4173', '4490', '4571', '4424', '4894', '4051', '4214', '4823', '4096', '4206', '4598', '4943', '4701', '4649', '4807', '4107', '4435', '4456', '4083', '4612', '4721', '4472', '4146', '4925', '4340', '4789', '4277', '4375', '4211', '4427', '4547', '4690', '4613', '4727', '4006', '4203', '4430', '4223', '4039', '4932', '4296', '4108', '4278', '4832', '4422', '4917', '4470', '4183', '4887', '4076', '4485', '4597', '4443', '4257', '4991', '4944', '4196', '4672', '4397', '4097', '4119', '4077', '4773', '4602', '4538', '4479', '4968', '4159', '4539', '4956', '4710', '4812', '4902', '4569', '4954', '4385', '4128', '4936', '4416', '4148', '4632', '4759', '4117', '4896', '4392', '4864', '4316', '4132', '4319', '4969', '4175', '4484', '4903', '4910', '4350', '4332', '4952', '4176', '4594', '4709', '4509', '4178', '4167', '4545', '4857', '4617', '4501', '4859', '4207', '4275', '4687', '4049', '4579', '4046', '4921', '4113', '4898', '4681', '4052', '4415', '4064', '4184', '4895', '4744', '4685', '4084', '4305', '4899', '4559', '4208', '4057', '4507', '4258', '4355', '4086', '4373', '4323', '4541', '4297', '4483', '4889', '4531', '4327', '4441', '4914', '4303', '4677', '4445', '4802', '4343', '4585', '4338', '4524', '4590', '4624', '4288', '4704', '4134', '4043', '4720', '4058', '4328', '4095', '4026', '4423', '4657', '4118', '4633', '4487', '4822', '4904', '4255', '4001', '4387', '4500', '4190', '4686', '4995', '4661', '4783', '4992', '4165', '4065', '4927', '4306', '4856', '4292', '4420', '4963', '4468', '4240', '4724', '4432', '4447', '4518', '4028', '4670', '4339', '4771', '4018', '4489', '4110', '4708', '4945', '4136', '4492', '4930', '4090', '4734', '4886', '4542', '4227', '4486', '4491', '4713', '4986', '4068', '4048', '4975', '4570', '4842', '4475', '4131', '4555', '4428', '4776', '4101', '4273', '4811', '4345', '5000', '4653', '4256', '4209', '4769', '4946', '4561', '4080', '4461', '4820', '4311', '4959', '4750', '4795', '4748', '4368', '4506', '4335', '4346', '4568', '4675', '4692', '4774', '4413', '4370', '4723', '4521', '4885', '4678', '4897', '4066', '4674', '4106', '4626', '4389', '4204', '4839', '4023', '4712', '4145', '4035', '4357', '4756', '4648', '4972', '4157', '4406', '4615', '4061', '4219', '4791', '4660', '4073', '4356', '4072', '4599', '4359', '4094', '4673', '4696', '4796', '4282', '4714', '4522', '4736', '4775', '4760', '4400', '4847', '4228', '4803', '4908', '4732', '4645', '4122', '4218', '4478', '4941', '4892', '4364', '4403', '4152', '4444', '4360', '4354', '4241', '4494', '4367', '4808', '4261', '4088', '4573', '4554', '4248', '4371', '4393', '4268', '4201', '4038', '4788', '4593', '4040', '4801', '4582', '4309', '4976', '4374', '4869', '4380', '4514', '4243', '4362', '4849', '4680', '4888', '4764', '4618', '4838', '4828', '4643', '4010', '4827', '4957', '4099', '4875', '4843', '4737', '4102', '4979', '4011', '4504', '4440', '4746', '4557', '4426', '4553', '4656', '4868', '4689', '4988', '4703', '4967', '4069', '4619', '4334', '4669', '4785', '4464', '4562', '4961', '4625', '4754', '4797', '4481', '4705', '4199', '4337', '4062', '4138', '4702', '4534', '4168', '4418', '4092', '4682', '4520', '4030', '4171', '4650', '4858', '4411', '4999', '4252', '4197', '4170', '4942', '4631', '4990', '4179', '4285', '4700', '4482', '4575', '4800', '4070', '4251', '4344', '4982', '4719', '4390', '4149', '4100', '4194', '4269', '4855', '4314', '4718', '4232', '4730', '4438', '4588', '4195', '4192', '4493', '4517', '4833', '4234', '4989', '4315', '4844', '4142', '4408', '4584', '4425']
4
+ a.unshift('aaa', 'bbb', 'ccc')
5
+ end
6
+ x.compare!
7
+ end
data/bin/opal-mspec CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'bundler/setup'
4
+
3
5
  specs = ARGV.map do |s|
4
6
  s.end_with?('.rb') ? s : "#{s}/**/*_spec.rb"
5
7
  end
data/docs/compiler.md CHANGED
@@ -21,7 +21,7 @@ The [opal parser][parser] relies on the `parser` gem, see debug/development docu
21
21
  The [opal compiler][compiler] takes these sexps from the parser
22
22
  and generates ruby code from them. Each type of sexp has [its own node type][base-node]
23
23
  used to generate javascript. Each node creates an array of one or more
24
- [fragments][fragments] which are the concatendated together to
24
+ [fragments][fragments] which are the concatenated together to
25
25
  form the final javascript. Fragments are used as they contain the generated
26
26
  code as well as a reference back to the original sexp which is useful for
27
27
  generating source maps afterwards.
@@ -2,4 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rack'
4
4
  gem 'opal', :path => '../../'
5
- gem 'c_lexer'
@@ -9,9 +9,6 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  ast (2.4.0)
12
- c_lexer (2.6.4.1.1)
13
- ast (~> 2.4.0)
14
- parser (= 2.6.4.1)
15
12
  parser (2.6.4.1)
16
13
  ast (~> 2.4.0)
17
14
  rack (2.0.7)
@@ -20,7 +17,6 @@ PLATFORMS
20
17
  ruby
21
18
 
22
19
  DEPENDENCIES
23
- c_lexer
24
20
  opal!
25
21
  rack
26
22
 
data/lib/opal/cli.rb CHANGED
@@ -133,6 +133,7 @@ module Opal
133
133
  irb_enabled
134
134
  inline_operators
135
135
  enable_source_location
136
+ use_strict
136
137
  parse_comments
137
138
  ]
138
139
  end
@@ -168,6 +168,10 @@ module Opal
168
168
  options[:enable_source_location] = true
169
169
  end
170
170
 
171
+ on('--use-strict', 'Enables JavaScript\'s strict mode (i.e., adds \'use strict\'; statement)') do
172
+ options[:use_strict] = true
173
+ end
174
+
171
175
  on('--parse-comments', 'Compiles comments for each method definition.') do
172
176
  options[:parse_comments] = true
173
177
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'shellwords'
3
4
  require 'opal/paths'
4
5
  require 'opal/cli_runners/system_runner'
5
6
 
@@ -14,10 +15,13 @@ module Opal
14
15
  argv = data[:argv].dup.to_a
15
16
  argv.unshift('--') if argv.any?
16
17
 
18
+ opts = Shellwords.shellwords(ENV['NODE_OPTS'] || '')
19
+
17
20
  SystemRunner.call(data) do |tempfile|
18
21
  [
19
22
  'node',
20
23
  '--require', "#{__dir__}/source-map-support-node",
24
+ *opts,
21
25
  tempfile.path,
22
26
  *argv
23
27
  ]
@@ -6147,7 +6147,9 @@ function CallSiteToString() {
6147
6147
  }
6148
6148
  var methodName = this.getMethodName();
6149
6149
  if (functionName) {
6150
- if (functionName.startsWith("$")) {
6150
+ if (functionName.startsWith("$$")) {
6151
+ functionName = functionName.slice(2);
6152
+ } else if (functionName.startsWith("$")) {
6151
6153
  functionName = functionName.slice(1);
6152
6154
  }
6153
6155
  if (typeName && functionName.indexOf(typeName) != 0) {
@@ -3403,7 +3403,9 @@ function CallSiteToString() {
3403
3403
  }
3404
3404
  var methodName = this.getMethodName();
3405
3405
  if (functionName) {
3406
- if (functionName.startsWith("$")) {
3406
+ if (functionName.startsWith("$$")) {
3407
+ functionName = functionName.slice(2);
3408
+ } else if (functionName.startsWith("$")) {
3407
3409
  functionName = functionName.slice(1);
3408
3410
  }
3409
3411
  if (typeName && functionName.indexOf(typeName) != 0) {
@@ -341,7 +341,9 @@ function CallSiteToString() {
341
341
  }
342
342
  var methodName = this.getMethodName();
343
343
  if (functionName) {
344
- if (functionName.startsWith("$")) {
344
+ if (functionName.startsWith("$$")) {
345
+ functionName = functionName.slice(2);
346
+ } else if (functionName.startsWith("$")) {
345
347
  functionName = functionName.slice(1);
346
348
  }
347
349
  if (typeName && functionName.indexOf(typeName) != 0) {