This repository has been archived by the owner. It is now read-only.

Only allow declares inside declare module #73

Merged
merged 2 commits into from Jul 29, 2016

Conversation

Projects
None yet
4 participants
@danez
Copy link
Member

danez commented Jul 10, 2016

This is the followup of #71

This now checks for the term declare being used inside declare module. Previously everything was allowed instead of declare. https://astexplorer.net/#/Y6hVjJkQ2m

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (2:2)"

This comment has been minimized.

@hzoo

hzoo Jul 12, 2016

Member

Is it possible to have a better error message here?

This comment has been minimized.

@danez

danez Jul 12, 2016

Author Member

Maybe something like: "Only declare statements are allowed inside declare module {}"

This comment has been minimized.

@hzoo

hzoo Jul 12, 2016

Member

Yeah something like that. Could even give an example (we haven't really done that)

I've been liking elm's errors/messages http://elm-lang.org/blog/compilers-as-assistants

@danez danez force-pushed the danez:check-declare branch from e8629e7 to 04cb0b7 Jul 28, 2016

@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Jul 28, 2016

Current coverage is 96.91% (diff: 100%)

Merging #73 into master will not change coverage

@@             master        #73   diff @@
==========================================
  Files            19         19          
  Lines          2922       2922          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           2832       2832          
  Misses           90         90          
  Partials          0          0          

Powered by Codecov. Last update f576865...3db8b0c

Daniel Tschinder
@danez

This comment has been minimized.

Copy link
Member Author

danez commented Jul 28, 2016

I changed the error message to be a little bit nicer.

pp.unexpected = function (pos) {
this.raise(pos != null ? pos : this.state.start, "Unexpected token");
pp.unexpected = function (pos, message = "Unexpected token") {
this.raise(pos != null ? pos : this.state.start, message);

This comment has been minimized.

@hzoo

hzoo Jul 28, 2016

Member

👍 I like being able to change the error message. Unexpected token is not fun to see (my example is function a() { await b; }) without async in front of function

@hzoo

This comment has been minimized.

Copy link
Member

hzoo commented Jul 28, 2016

k 👍 , @jeffmo

@gabelevi

This comment has been minimized.

Copy link
Contributor

gabelevi commented Jul 29, 2016

👍 this looks correct to me. Everything inside of a declare module declaration does start with declare.

@danez danez merged commit eb69142 into babel:master Jul 29, 2016

3 checks passed

codecov/patch 100% of diff hit (target 96.91%)
Details
codecov/project 96.91% (+0.00%) compared to f576865
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@danez danez deleted the danez:check-declare branch Jul 29, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.