Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prototypes of literals in the REPL #1425

Closed
ghost opened this issue Jun 8, 2011 · 4 comments
Closed

prototypes of literals in the REPL #1425

ghost opened this issue Jun 8, 2011 · 4 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Jun 8, 2011

If I run the below code in a script, it works fine. But when I run it in the Coffee REPL, the test prototype isn't set.

Object::test = -> console.log 'test'
a = {}
(console.log k + ', ' + v) for k, v of a

I'm using CoffeeScript 1.1.1.

@michaelficarra
Copy link
Collaborator

This is fixed on master. See issue #1390 and 454aa84, the commit that fixed it.

edit: incorrect, see below.

@satyr
Copy link
Collaborator

satyr commented Jun 8, 2011

This is fixed on master

Really?

$ git log -1 --oneline
dfcff3f adding regression test for #1420; also cleaned up a little trailing ...

$ bin/coffee -i
coffee> 0.__proto__.double = -> @ * 2
[Function]
coffee> 1.double()
TypeError: Object 1 has no method 'double'

FYI:

coco>  0.__proto__.double = -> @ * 2
[Function]
coco> 1.double()
2

@michaelficarra
Copy link
Collaborator

Ah, I see the problem. Literals are not constructed from their respective natives:

$;node
> 0..constructor === Number
true
$;coffee
coffee> 0.constructor is Number
false

@satyr satyr reopened this Jun 8, 2011
@ghost ghost assigned michaelficarra Jun 24, 2011
michaelficarra added a commit that referenced this issue Jul 6, 2011
CoffeeScript.eval. Instead of writing about all the changes and why I
made those decisions, I'll just answer any questions in the commit
comments, so add a commit comment if you want to question anything.
Thanks to @TrevorBurnham and @satyr for their help/contributions. Also,
closes #1487. And still no REPL tests...
@michaelficarra
Copy link
Collaborator

Fixed by fff4c9c

michaelficarra added a commit that referenced this issue Jul 7, 2011
CoffeeScript.eval. Instead of writing about all the changes and why I
made those decisions, I'll just answer any questions in the commit
comments, so add a commit comment if you want to question anything.
Thanks to @TrevorBurnham and @satyr for their help/contributions. Also,
closes #1487. And still no REPL tests...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants