Code Monkey home page Code Monkey logo

es6draft's People

Contributors

anba avatar jugglinmike avatar leobalter avatar mathiasbynens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

es6draft's Issues

Rename the project?

The project name implies it doesn’t implement ES6/ES2015 fully, let alone more recent additions to the spec. But this is not true!

Don’t be modest :) Have you considered renaming the project to something less ephemeral?

Return and inner generators

I am currently experimenting with es6draft, and I am wondering whether its behaviour with the following piece of code is correct:

function* f2() {
  function* g() {
    try {
      yield 1;
      yield 2;
    } finally {
      yield 3;
      print("Should be reachable???");
      yield 4;
    }
  }
  yield* g();
  yield 5;
}

var g2 = f2();
g2.next();  // -> yields {value: 1, done: false}
g2.return(42); // -> yields {value: 3, done: true}
g2.next(); // -> yields {value: undefined, done: true}

The comments of the form // -> show what es6draft returns. Is this behaviour really the one that is intended by the latest draft of ES6? For example, the print statement in the finally clause is never being executed.

(Reading the spec, it looks to me that es6draft is correct in its behaviour, but does it make sense?)

Do you have something like docs?

I'm reading your code and trying to understand, I konw you write the code base on ecmascript specification, but there are some terms or explaination that I can't understand.

So I want to know whether you have some extra docs to help me to understand, thank you very much.

crash in RegExp.prototype[ @@replace ]

js> (new class extends RegExp {
  exec(){
    return {index: 0};
  }
})[Symbol.replace]("a", "b")
java.lang.NullPointerException
    at com.github.anba.es6draft.runtime.objects.text.RegExpPrototype$Properties.replace(RegExpPrototype.java:470)
    at #typein_1.~script(typein:3)
    at com.github.anba.es6draft.runtime.internal.RuntimeInfo$CompiledScriptBody.evaluate(RuntimeInfo.java:310)
    at com.github.anba.es6draft.compiler.CompiledScript.evaluate(CompiledScript.java:28)
    at com.github.anba.es6draft.Scripts.ScriptEvaluation(Scripts.java:50)
    at com.github.anba.es6draft.repl.Repl.eval(Repl.java:782)
    at com.github.anba.es6draft.repl.Repl.access$300(Repl.java:97)
    at com.github.anba.es6draft.repl.Repl$InteractiveTaskSource$EvalPrintTask.execute(Repl.java:911)
    at com.github.anba.es6draft.runtime.World.executeTasks(World.java:221)
    at com.github.anba.es6draft.runtime.World.runEventLoop(World.java:198)
    at com.github.anba.es6draft.repl.Repl.loop(Repl.java:808)
    at com.github.anba.es6draft.repl.Repl.main(Repl.java:108)

Incorrect Function Length

The ES6 spec defines Symbol.prototype[Symbol.toPrimitive] as a function with a single parameter.
According to section 17, in the absence of any text specifying otherwise, the function's length property value should be dictated by its formal parameter list:

Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this value
is equal to the largest number of named arguments shown in the subclause
headings for the function description, including optional parameters.

This is a bit disappointing because the parameter isn't actually referenced in the algorithm, but I believe following the letter of the spec means defining the length property to 1.

Interpret the dash(-) argument as /dev/stdin

I'm afraid I can't explain myself very well due to my bad english, so I will give you some examples to demonstrate:

$ pbpaste
var foo = Number
`123`
print(typeof foo)

SpiderMonkey:

pbpaste | js
js> var foo = Number
js> `123`
"123"
js> print(typeof foo)
function

$ pbpaste | js -
number

es6draft:

$ pbpaste | ./es6draft
js> var foo = Number
js> `123`
"123"
js> print(typeof foo)
function

$ pbpaste | ./es6draft -
"-" is not a valid option

$ pbpaste | ./es6draft /dev/stdin
number

Function `name` property incorrectly derived from description-less Symbol

When a function's name property is derived from a Symbol value that has no
description, the name should be "[]".

$ ./bin/es6draft --version
es6draft rev38 (build: 2015-07-06T15:04:38)
$ ./bin/es6draft -e 'var s = Symbol(); var o = { [s]: ()=>{} }; print(o[s].name);'

$

(espected: "[]")

19.4.1.1 Symbol ( [ description ] )

When Symbol is called with optional argument description, the following steps
are taken:

  1. If NewTarget is not undefined, throw a TypeError exception.
  2. If description is undefined, let descString be undefined.
  3. Else, let descString be ToString(description).
  4. ReturnIfAbrupt(descString).
  5. Return a new unique Symbol value whose [[Description]] value is descString.

9.2.11 SetFunctionName (F, name, prefix)

The abstract operation SetFunctionName requires a Function argument F, a
String or Symbol argument name and optionally a String argument prefix. This
operation adds a name property to F by performing the following steps:

  1. Assert: F is an extensible object that does not have a name own property.
  2. Assert: Type(name) is either Symbol or String.
  3. Assert: If prefix was passed then Type(prefix) is String.
  4. If Type(name) is Symbol, then
    1. Let description be name’s [[Description]] value.
    2. If description is undefined, let name be the empty String.
    3. Else, let name be the concatenation of "[", description, and "]".
  5. If prefix was passed, then
    1. Let name be the concatenation of prefix, code unit 0x0020 (SPACE), and
      name.
  6. Return DefinePropertyOrThrow(F, "name", PropertyDescriptor{[[Value]]:
    name, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
    true}).
  7. Assert: the result is never an abrupt completion.

Rewrite in C++

I have to admit that I haven't taken a closer look at your code base. Do you think it is feasible to translate your work form Java to C++? In the latter case it could be compiled with Emscripten and after adapting it to the browser environment, one would have a nearly 100% complete implementation for ES6 on the browser. (And would be prepared when ES7 is specced.)

With asm.js, I don't think it would run slower than the current code in the JVM.

Crash when parsing RegularExpressionLiteral PropertyName

js> ({/ /(){}})
java.lang.AssertionError
    at com.github.anba.es6draft.parser.TokenStream.peekToken(TokenStream.java:372)
    at com.github.anba.es6draft.parser.Parser.SAFE_LOOKAHEAD(Parser.java:1810)
    at com.github.anba.es6draft.parser.Parser.propertyDefinition(Parser.java:7558)
    at com.github.anba.es6draft.parser.Parser.objectLiteral(Parser.java:7386)
    at com.github.anba.es6draft.parser.Parser.primaryExpression(Parser.java:6921)
    at com.github.anba.es6draft.parser.Parser.leftHandSideExpression(Parser.java:7986)
    at com.github.anba.es6draft.parser.Parser.unaryExpression(Parser.java:8242)
    at com.github.anba.es6draft.parser.Parser.binaryExpression(Parser.java:8343)
    at com.github.anba.es6draft.parser.Parser.assignmentExpression(Parser.java:8507)
    at com.github.anba.es6draft.parser.Parser.assignmentExpressionNoValidation(Parser.java:8466)
    at com.github.anba.es6draft.parser.Parser.coverParenthesizedExpressionAndArrowParameterList(Parser.java:7001)
    at com.github.anba.es6draft.parser.Parser.primaryExpression(Parser.java:6932)
    at com.github.anba.es6draft.parser.Parser.leftHandSideExpression(Parser.java:7986)
    at com.github.anba.es6draft.parser.Parser.unaryExpression(Parser.java:8242)
    at com.github.anba.es6draft.parser.Parser.binaryExpression(Parser.java:8343)
    at com.github.anba.es6draft.parser.Parser.assignmentExpression(Parser.java:8507)
    at com.github.anba.es6draft.parser.Parser.assignmentExpression(Parser.java:8451)
    at com.github.anba.es6draft.parser.Parser.expression(Parser.java:8922)
    at com.github.anba.es6draft.parser.Parser.expressionStatement(Parser.java:5585)
    at com.github.anba.es6draft.parser.Parser.statement(Parser.java:4933)
    at ...(Frames omitted:13)

Promise.resolve does not honor `constructor` property

If Promise.resolve is invoked with a Promise instance as its first argument,
that object should only be returned if its constructor property matches the
current "this" value.

$ ./bin/es6draft --version
es6draft rev38 (build: 2015-07-06T15:04:38)
$ ./bin/es6draft
js> var p1 = new Promise(function() {});
js> p1.constructor = null;
null
js> Promise.resolve(p1) === p1
true

(expected: false)

25.4.4.5 Promise.resolve ( x )

  1. Let C be the this value.
  2. If Type(C) is not Object, throw a TypeError exception.
  3. If IsPromise(x) is true,
    1. Let xConstructor be Get(x, "constructor").
    2. ReturnIfAbrupt(xConstructor).
    3. If SameValue(xConstructor, C) is true, return x.

See also:

Misbehaving RegExp-likes can crash the VM

If a "RegExp-like" object sets its own lastIndex property to an out-of-bounds
value during a "split" operation, es6draft will crash.

Example:

var obj = {
  constructor: function() {}
};
var fakeRe = {
  exec: function() {
    fakeRe.lastIndex = 999;
    return [];
  }
};
obj.constructor[Symbol.species] = function() {
  return fakeRe;
};

RegExp.prototype[Symbol.split].call(obj, 'a');

Produces the following error:

java.lang.StringIndexOutOfBoundsException: String index out of range: -998
  at java.lang.String.substring(String.java:1955)
  at com.github.anba.es6draft.runtime.objects.text.RegExpPrototype$Properties.split(RegExpPrototype.java:672)
  at com.github.anba.es6draft.runtime.types.builtins.NativeFunction.call(NativeFunction.java:97)
  at com.github.anba.es6draft.runtime.types.builtins.BuiltinFunction.tailCall(BuiltinFunction.java:206)
  at com.github.anba.es6draft.runtime.internal.TailCallInvocation$CallTailCallInvocation.apply(TailCallInvocation.java:66)
  at com.github.anba.es6draft.runtime.internal.TailCallInvocation.tailCallTrampoline(TailCallInvocation.java:179)
  at #typein_1.~script_code(/test262/tmp2.js:14)
  at #typein_1.!script(/test262/tmp2.js:1)
  at com.github.anba.es6draft.runtime.internal.RuntimeInfo$CompiledScriptBody.evaluate(RuntimeInfo.java:233)
  at com.github.anba.es6draft.compiler.CompiledScript.evaluate(CompiledScript.java:29)
  at com.github.anba.es6draft.repl.Repl.eval(Repl.java:801)
  at com.github.anba.es6draft.repl.Repl.access$300(Repl.java:89)
  at com.github.anba.es6draft.repl.Repl$ScriptEvaluationTask.execute(Repl.java:1146)
  at com.github.anba.es6draft.runtime.World.executeTasks(World.java:223)
  at com.github.anba.es6draft.runtime.World.runEventLoop(World.java:200)
  at com.github.anba.es6draft.repl.Repl.loop(Repl.java:827)
  at com.github.anba.es6draft.repl.Repl.main(Repl.java:100)

Here's the relevant source code:

/* step 25 */
String t = s.substring(p, size);

This seems like it may be an omission in the spec itself, since an explicit
RangeError might be appropriate here. I've opened a bug on the spec bug tracker
to discuss that possibility: https://bugs.ecmascript.org/show_bug.cgi?id=4434

As it stands, though, the most logical behavior may be to silently skip
appending the final string value.

Reflect.parse crash with "ImportClause : ImportedDefaultBinding , NamedImports"

js> Reflect.parse(`import a,{b} from ""`)
com.github.anba.es6draft.runtime.objects.reflect.ReflectParser$NotImplementedExpception: class com.github.anba.es6draft.ast.ImportClause
    at com.github.anba.es6draft.runtime.objects.reflect.ReflectParser.visit(ReflectParser.java:1552)
    at com.github.anba.es6draft.runtime.objects.reflect.ReflectParser.visit(ReflectParser.java:42)
    at com.github.anba.es6draft.ast.ImportClause.accept(ImportClause.java:42)
    at com.github.anba.es6draft.runtime.objects.reflect.ReflectParser.visit(ReflectParser.java:1523)
    at com.github.anba.es6draft.runtime.objects.reflect.ReflectParser.visit(ReflectParser.java:42)
    at com.github.anba.es6draft.ast.ImportDeclaration.accept(ImportDeclaration.java:51)
    at com.github.anba.es6draft.runtime.objects.reflect.ReflectParser.createList(ReflectParser.java:416)
    at com.github.anba.es6draft.runtime.objects.reflect.ReflectParser.visit(ReflectParser.java:1718)
    at com.github.anba.es6draft.runtime.objects.reflect.ReflectParser.visit(ReflectParser.java:42)
    at com.github.anba.es6draft.ast.Module.accept(Module.java:61)
    at com.github.anba.es6draft.runtime.objects.reflect.ReflectParser.parse(ReflectParser.java:275)
    at com.github.anba.es6draft.runtime.objects.reflect.ReflectParser.parse(ReflectParser.java:239)
    at com.github.anba.es6draft.runtime.objects.reflect.Reflect$ParseProperty.parse(Reflect.java:509)
    at #typein_1.~script(typein:1)
    at com.github.anba.es6draft.runtime.internal.RuntimeInfo$CompiledScriptBody.evaluate(RuntimeInfo.java:289)
    at com.github.anba.es6draft.compiler.CompiledScript.evaluate(CompiledScript.java:28)
    at com.github.anba.es6draft.Scripts.ScriptEvaluation(Scripts.java:44)
    at com.github.anba.es6draft.repl.Repl.eval(Repl.java:785)
    at com.github.anba.es6draft.repl.Repl.access$300(Repl.java:97)
    at com.github.anba.es6draft.repl.Repl$InteractiveTaskSource$EvalPrintTask.execute(Repl.java:914)
    at ...(Frames omitted:4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.