Skip to content

Super/Aliasing Fix#1385

Merged
elia merged 2 commits intoopal:masterfrom
wied03:super_method_fix
Mar 24, 2016
Merged

Super/Aliasing Fix#1385
elia merged 2 commits intoopal:masterfrom
wied03:super_method_fix

Conversation

@wied03
Copy link
Copy Markdown
Contributor

@wied03 wied03 commented Mar 6, 2016

Fixes #1384. Another weird quirk of the Ruby language (if it's a weird corner, RSpec will find it). It still needs the following:

  • Rubyspec built from the anon_mod.rb file done
  • This is probably incomplete as it really needs to be something that also fixes the Rubyspec Module#alias_method can call a method with super aliased twice save this for another PR

@wied03 wied03 mentioned this pull request Mar 6, 2016
33 tasks
@wied03
Copy link
Copy Markdown
Contributor Author

wied03 commented Mar 10, 2016

@meh - any thoughts here?

Opal.defn = function(obj, jsid, body) {
obj.$$proto[jsid] = body;
// super dispatcher find, etc. might need to lookup by function body
obj.$$funcbodies[body] = jsid;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rings an alarm for me, [body] will convert the function to a string and use that as the key, which means that will use the actual source code of the function to identify it. That, to me, is a problem because:

  • two methods in the inheritance chain can have the same implementation this defeating this technique (even if I'm aware it's surely not common)
  • I'm not sure how standard is to have Function.prototype.toString() converto the function to its source code, what if the implementation is changed?
  • looks like a hack
  • could mislead a future me reading this code

Even if I recognize it's practical, I'd rather prefer to have a more robust system, that actually checks a prototype chain for the particular method or alternatively assign an Opal.uid() to each function and use that instead of the function body.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the first way/first commit?

sent from my mobile device
On Mar 20, 2016 7:24 PM, "Elia Schito" notifications@github.com wrote:

In opal/corelib/runtime.js
#1385 (comment):

@@ -1347,6 +1356,8 @@
//
Opal.defn = function(obj, jsid, body) {
obj.$$proto[jsid] = body;

  • // super dispatcher find, etc. might need to lookup by function body
  • obj.$$funcbodies[body] = jsid;

This rings an alarm for me, [body] will convert the function to a string
and use that as the key, which means that will use the actual source code
of the function to identify it. That, to me, is a problem because:

  • two methods in the inheritance chain can have the same
    implementation this defeating this technique (even if I'm aware it's surely
    not common)
  • I'm not sure how standard is to have Function.prototype.toString()
    converto the function to its source code, what if the implementation is
    changed?
  • looks like a hack
  • could mislead a future me reading this code

Even if I recognize it's practical, I'd rather prefer to have a more
robust system, that actually checks a prototype chain for the particular
method or alternatively assign an Opal.uid() to each function and use
that instead of the function body.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/opal/opal/pull/1385/files/479badbfb12bc716720a7cb34ffebc7588cca44b#r56777155

@wied03 wied03 force-pushed the super_method_fix branch 2 times, most recently from 37e6cc5 to 159ea8f Compare March 21, 2016 04:12
@wied03
Copy link
Copy Markdown
Contributor Author

wied03 commented Mar 21, 2016

rubyspecs - ruby/spec#212

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 87.643% when pulling 37e6cc5 on wied03:super_method_fix into 4964053 on opal:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 87.643% when pulling 159ea8f on wied03:super_method_fix into 4964053 on opal:master.

@wied03
Copy link
Copy Markdown
Contributor Author

wied03 commented Mar 21, 2016

@elia - Thanks for the earlier feedback. I think with this 2nd commit, I got the nested loop eliminated and have something that can work OK.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 87.643% when pulling e9cb107 on wied03:super_method_fix into 4964053 on opal:master.

@wied03 wied03 force-pushed the super_method_fix branch from 339b66d to b454d66 Compare March 21, 2016 14:02
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.09%) to 87.733% when pulling b454d66 on wied03:super_method_fix into 4964053 on opal:master.

@wied03 wied03 force-pushed the super_method_fix branch from b454d66 to 61d3e2c Compare March 23, 2016 21:14
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 87.621% when pulling 61d3e2c on wied03:super_method_fix into 0815306 on opal:master.

@elia elia merged commit 7b5c95f into opal:master Mar 24, 2016
@elia
Copy link
Copy Markdown
Member

elia commented Mar 24, 2016

👍 :)

@wied03 wied03 deleted the super_method_fix branch March 24, 2016 03:16
hmdne pushed a commit to hmdne/opal that referenced this pull request Jan 27, 2024
Bumps [eslint](https://github.com/eslint/eslint) from 7.31.0 to 7.32.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.31.0...v7.32.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Super/Alias Problem

3 participants