47 Commits

Author SHA1 Message Date
Gonzalo Rodríguez
69d00dc5b0 [parser] Invalid NonOctal Decimal (#10467)
* Add test

* Add nonOctalDecimal verification

* Update regex and code style

* Refactor non octal detection

* Add numeric separator test

* Disallow numeric separators in non octals

* Update whitelist

* Better test naming

* Disallow numeric separators in non oct for all numbers

* Specific error above the general error

* Add test for invalid leading zero in num separator

* Add start position to error
2019-09-23 23:07:52 +02:00
Ivan Medina
f339d2d034 [parser] Disallow numeric separator in unicode scape sequences (#10468)
* [parser] Disallow numeric separator in unicode scape sequences (#10460)

* raise error only when numeric separator plugin is set

* Adds argument for checking numeric separator

* Fix condition for readability

* Add test for hex escape sequence and rephrase error message

* Remove exposure for allowNumSeparator in readHexChar method
2019-09-23 22:47:18 +02:00
Vivek Nayyar
b7333ea97a added check to disallow super.private variable access and test case added (#10472)
* 🚀 added check to disallow super.private variable access and test case added

* ♻️ change the other linting change back to how it was

* ♻️ change the other linting change back to how it was

* ♻️ added newline at the end test output.json file

* ♻️ changed the linting style to the way it was

* ♻️ updated error message, removed super private member access test cases from whitelist of flow and test 262 suite

* ♻️ added newline in output.json
2019-09-21 00:22:37 +02:00
Guy Waldman
9c1ad0a9f7 [parser] Disallow static fields named constructor (#10461)
* Disallow static fields named `constructor` in a class

    - Disallowed static fields named `constructor` in a class (previously only non-static were disallowed)
    - Updated the text for the error for one consolidated warning, for both static and non-static fields
    - Added a test
    - Updated an existing test in the `flow` test suite of the parser to reflect the parse error.
  Strangely, the test used to pass and started failing when inlining the `isNonstaticConstructor` method, without any changes.
  In that test, `constructor` was a field, so in theory it should never have passed.
  Would appreciate some feedback on this, as I'm not 100% sure if this is somehow related to Flow

* Update test262 whitelist

* Add comment and fix && operator
2019-09-18 01:19:45 +02:00
Vivek Nayyar
b02e35c19a Fix parenthesis for nullish coalescing (#10269)
* ♻️ added condition to check for left and right of nullish coalescing operator and if any is a logical expression without a paren then throw an error

* 🐛 bugs fixed and test cases updated for babel parser

* ♻️ code comments added

* 🐛 spell error rectified

* ♻️ failing test updated

* 🐛 push tests after make build

* Skip nullish-coalescing flow precedence tests

They're now incorrect

* ♻️ error message updated, binop priority of other logical operators +1 from ?? and

* ♻️ increaed the binOp for in and instanceOf, added logic to print the brackets in an ?? && || expression, test cases added

* 🐛 failing test fixed and comments updated

* ♻️ new lines added between tests

* ♻️ basic tests for checking the binOp of instanceOf, in and relational operators to be equal added

* ♻️ new lines added in between tests
2019-09-06 17:35:44 +02:00
James DiGioia
6b8a37c413 Implement f# pipeline in parser (#9450) 2019-06-30 12:53:22 +02:00
Nicolò Ribaudo
8bf9714d69
[legacy decorators] Allow decorating generator methods (#9912)
* [legacy decorators] Allow decorating generator methods

The old proposal used LeftHandSideExpression (instead of
AssignmentExpression) to satisfy this usecase:
e240cbc91a

* Update flow whitelist
2019-06-30 11:32:16 +02:00
Daniel Tschinder
85432e2c44
Remove guardedHandlers from ASTs (#9979) 2019-05-15 03:37:22 -07:00
Behrang Yarahmadi
29cd27b545 Partial application plugin (#9474)
* add partial application syntax and some tests

remove unnecessary error message and hasPartial function from parseNewArguments

add types for PartialExpression

Update the tests

rename PartialExpression to Partial

move Partial from expressions to types and rename to ArgumentPlaceholder

add tests for ArgumentPlaceholder in babel-generator

rename Partial to ArgumentPlaceholder

update the tests

remove alias from the type and undo changes in generated folder

adds a nice error message

better definition for the type

auto-generated files

update the conditional for allowPlaceholder message and tests

update CallExpression definition to accept ArgumentPlaceholder

change description

clean up

indent ArgumentPlaceholder entry and revert unwanted changes

* add Partial Application Plugin

* update unwrapArguments function and add replacePlaceholders.

* update the tests

* remove unnecessary clone

* update readme and description an package.json

* put options.json one level up and add test for not assigned and chained

* add await to fix the test

* use Promise in the test instead of async await

* remove unnecessary method test [#9474]

* push sequenceExpressions to an array [#9474]
2019-03-13 12:21:10 +01:00
Nicolò Ribaudo
d832c0f434
Add parser support for placeholders (#9364) 2019-03-05 00:45:42 +01:00
Behrang Yarahmadi
c60c4dd375
Partial Application Syntax: Stage 1 (#9343)
* add partial application syntax and some tests

* remove unnecessary error message and hasPartial function from parseNewArguments

* add types for PartialExpression

* Update the tests

* rename PartialExpression to Partial

* move Partial from expressions to types and rename to ArgumentPlaceholder

* add tests for ArgumentPlaceholder in babel-generator

* rename Partial to ArgumentPlaceholder

* update the tests

* remove alias from the type and undo changes in generated folder

* adds a nice error message

* better definition for the type

* auto-generated files

* update the conditional for allowPlaceholder message and tests

* update CallExpression definition to accept ArgumentPlaceholder

* change description

* clean up

* indent ArgumentPlaceholder entry and revert unwanted changes
2019-03-05 00:34:02 +01:00
Daniel Tschinder
a7391144b3
Introduce scope tracking in the parser (#9493)
* Introduce scope tracking

* Fix tests

* Add new tests

* Remove constructor-super check from transform as it is now in parser

* Correctly handle class properties and class scope

* Fix duplicate name check

* Convert scope identifier storage to array

* Enter a new scope in typescript module blocks

* Add test for duplicate declaration

* Rename error for duplicate exports

* Treat class declarations as lexical declaration

* Update whitelist

* Add tests

* Fix scope tracking for function declarations

* Migrate try-catch duplicate error

* Fix test

* More tests

* One more test

* Make scope a separate class and fix review comments

* Do not allow new.target in top scope arrow function

* Correctly enter new scope for declare module and treat type aliases as lexical declarations

* Tests for typescript scope tracking to not mark type aliases as duplicate

* Fix flow scope tracking

* Remove ident from test names as redundant

* Add test case for var and function

* Improve error messages

* Improve literal regex
2019-02-25 11:04:52 -08:00
Daniel Tschinder
a1ea765b95
Make tests spec compliant and avoid duplicate declarations in input files (#9522) 2019-02-18 16:14:35 -08:00
Brian Ng
7dc157f9be
Fix location/range on TypeScript ExportNamedDeclarations (#9406) 2019-01-24 19:44:22 -06:00
Nicolò Ribaudo
65febdd13a
Refactor import and export parsing (#9326)
* [parser] Refactor import parsing

* [parser] Refactor export parsing

* Fix types
2019-01-22 19:52:56 +01:00
Brian Ng
f77c450cda
Bump prettier (#9373) 2019-01-22 09:16:32 -06:00
Nicolò Ribaudo
5889620a6a
Disallow new import(x) and import(x,) (#9313)
* Disallow "new import(...)"

* Disallow trailing comma inside dynamic import

* Rename test

* Update error message
2019-01-11 18:59:51 +01:00
J. S. Choi
c586d4e8ca parser, smart pipes: Add support for yield in pipeline bodies
Fixes #9178.
2018-12-23 17:09:18 +01:00
J. S. Choi
60ffe1d103 parser, smart pipes: Add test for async–await 2018-12-23 17:09:18 +01:00
Sven Sauleau
fdc869ce16
Merge pull request #8289 from valtech-nyc/implement-smart-pipeline-in-parser
Implement Smart Pipeline proposal in @babel/parser
2018-12-03 19:28:45 +01:00
mAAdhaTTah
70318c9413 s/may/should 2018-11-21 16:02:34 -05:00
mAAdhaTTah
6e84352b51 PrimaryTopicReference -> PipelinePrimaryTopicReference 2018-11-21 15:54:56 -05:00
Nicolò Ribaudo
24c4901ff5
Remove Babylon plugins for features already merged to the ECMAScript spec (#8448)
These are now enabled by default:
- objectRestSpread (2018)
- asyncGenerators (2018)
- optionalCatchBInding (2019)
- jsonStrings (2019)

TODO (after this commit):
- [ ] Deprecate the `@babel/plugin-syntax-*` packages.
- [ ] Deprecate the `@babel/plugin-proposal-*` packages.
- [ ] Create the `@babel/plugin-transform-*` packages.
2018-11-05 23:48:06 +01:00
mAAdhaTTah
4521204ea0 Merge branch 'master' into implement-smart-pipeline-in-parser
* master: (222 commits)
  Set correct methods name
  Use toPropertyKey in the "decorate" helper
  Allow function types in type params within arrow return types (#8954)
  Fix message when plugin of a wrong type is passed (#8950)
  rename colliding let bindings with for loop init (#8937)
  edge incomplete support for arrow destructuring (babel #8349) (#8926)
  fix single-arg async arrows when retainLines=true (#8868)
  [flow] Explicit inexact objects with `...` (#8884)
  Update preset-env data (#8898)
  Treat break inside block inside loop (#8914)
  fixed "source map" formatting in comment (#8878) [skip ci]
  fix typo in contributing guidelines (#8901) [skip ci]
  fix: Expression x === 'y' && '' should not evaluate to undefined. (#8880)
  fixed an extra word
  Fixes #8865 (#8866)
  v7.1.4
  v7.1.3
  Bump Babel deps (#8770)
  flow-bin@0.82.0 (#8832)
  Insertafter jsx fix (#8833)
  ...

# Conflicts:
#	packages/babel-parser/src/tokenizer/index.js
#	packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-literal/options.json
#	packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json
2018-11-03 14:00:12 -04:00
Byron Luk
929567523c Fixes #8865 (#8866) 2018-10-12 09:28:15 -05:00
Bruno Macabeus
850bc1d3dd class private methods and properties: should not allow spaces between # and identifier (#8756) 2018-10-02 19:31:06 -07:00
Brian Ng
38cf318f61
Bump lint-related deps (#8765) 2018-09-24 18:09:54 -05:00
Logan Smyth
79b2af5997
Format fixture JSON with Prettier. (#8658) 2018-09-09 17:57:52 -07:00
Nicolò Ribaudo
9d244ae66b More helpful error message for missing decoratorsBeforeExport in parser (#8576) 2018-08-29 09:02:18 -05:00
Nicolò Ribaudo
d79b5eeeff
Require decoratorsBeforeExport option for decorators (#8465)
* Require decoratorsBeforeExport option for syntax-decorators

* Also babylon

* Enable test
2018-08-15 09:04:52 +02:00
James DiGioia
122906d525 Verify if MemberExpression is computed
If a property access is computed, e.g. a[b], then it's in topic style. Currently,
this isn't accounted for. Test & change ensures this doesn't parse.
2018-08-10 08:06:38 -04:00
James DiGioia
25d01460fd Fix error message for #4 case
This impact private fields as well as smart pipeline, providing a clearer
error message for both.
2018-08-10 07:52:55 -04:00
James DiGioia
ba5642d4ee Add test for computer properties
This seems to parse fine. Should it?
2018-08-09 22:08:39 -04:00
James DiGioia
15e6d844ae Remove additional parser logic
These are parsable only in follow-on proposals, not in the base proposal,
so we'll introduce that in a separate PR.
2018-08-09 22:08:23 -04:00
James DiGioia
afd0638b74 Reuse hash token instead of new primaryTopicToken
Set whether we're in a pipeline in order to determine how to parse the
hash. The error message changes as a result, since the `hash` never
enters the block.
2018-07-22 18:46:31 -04:00
dnalborczyk
8b10a44fe1 remove .then from dynamic import parser exception message (#8355) 2018-07-21 08:26:17 +02:00
James DiGioia
cc526940ee Quote proposals in error message 2018-07-12 23:07:09 -04:00
J. S. Choi
fbf62b4830 Implement Smart Pipeline proposal in @babel/parser 2018-07-09 22:44:27 -04:00
James DiGioia
19a1705293 Support pipeline proposal flag in @babel/parser (#8291) 2018-07-09 16:59:56 -04:00
Nicolò Ribaudo
6349118bed
Change decoratorsBeforeExport default to false (#8113) 2018-06-04 21:12:01 +02:00
Nicolò Ribaudo
b8dcd6f593
Remove parser support for decorators optional parentheses (#8037)
* Remove parser support for decorators optional parentheses

* Update fixtures
2018-06-02 13:07:15 +02:00
dnalborczyk
fe556c502d fix folder name (#8074) 2018-06-01 17:58:37 +02:00
Erik Arvidsson
2a8ebbe7ae Remove parenthesizedArgument (#7981)
The extra field parenthesizedArgument was never set to true. It was
always set to false and the code that read this was incorrectly
checking if extra was present.

Fixes #7957
2018-05-29 13:58:21 -07:00
Nicolò Ribaudo
b33823e7f8 Better error message for invalid decorators syntax (#7986) 2018-05-23 15:26:35 -04:00
Logan Smyth
2058e0686e Add support for an InterpreterDirective AST node. 2018-05-21 18:19:58 -07:00
Justin Ridgewell
0879a6d608
Subsume json (#7985)
* Add Subsume JSON transform

https://github.com/tc39/proposal-json-superset is at stage 3.

This allows U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR to appear unescaped inside strings and directives.

* Move to Stage 3

* Break diretive parsing

* Update README

* Handle multi-escape sequences

* Remove babylon files after rename
2018-05-19 15:32:05 -04:00
Chaitanya Kumar Kamatham
daf0ca8680 Rename "babylon" to "@babel/parser" (#7937) 🎉 2018-05-19 00:03:05 -04:00