From ac90a1ecc986b024612493db3177095827cb3724 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Mon, 30 Jul 2018 17:45:18 +0800 Subject: [PATCH 1/4] Move some builtins to chapter 3 --- src/createContext.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/createContext.ts b/src/createContext.ts index b3f909773..16c4e30c6 100644 --- a/src/createContext.ts +++ b/src/createContext.ts @@ -125,10 +125,15 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn defineSymbol(context, 'equal', list.equal) } + if (context.chapter >= 3) { + defineSymbol(context, 'set_head', list.set_head) + defineSymbol(context, 'set_tail', list.set_tail) + defineSymbol(context, 'array_length', misc.array_length) + } + if (context.chapter >= Infinity) { // previously week 4 defineSymbol(context, 'alert', alert) - defineSymbol(context, 'math_floor', Math.floor) // tslint:disable-next-line:ban-types defineSymbol(context, 'timed', (f: Function) => misc.timed(context, f, context.externalContext, externalBuiltIns.display)) // previously week 5 @@ -136,12 +141,6 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn defineSymbol(context, 'draw', visualiseList) // previously week 6 defineSymbol(context, 'is_number', misc.is_number) - // previously week 8 - defineSymbol(context, 'undefined', undefined) - defineSymbol(context, 'set_head', list.set_head) - defineSymbol(context, 'set_tail', list.set_tail) - // previously week 9 - defineSymbol(context, 'array_length', misc.array_length) } } From ada4467f34509173e8a836db954518353f356989 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Mon, 30 Jul 2018 18:08:40 +0800 Subject: [PATCH 2/4] Move some syntax rules to chapter 3 --- src/syntaxTypes.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/syntaxTypes.ts b/src/syntaxTypes.ts index 2ebbfb2c5..e150f4df0 100644 --- a/src/syntaxTypes.ts +++ b/src/syntaxTypes.ts @@ -19,21 +19,21 @@ const syntaxTypes: { [nodeName: string]: number } = { // Chapter 2 ArrayExpression: 2, + // Chapter 3 + AssignmentExpression: 3, + ForStatement: 3, + WhileStatement: 3, + BreakStatement: 3, + ContinueStatement: 3, + ThisExpression: 3, + ObjectExpression: 3, + MemberExpression: 3, + Property: 3, + UpdateExpression: 3, + // Week 5 EmptyStatement: 5, - // preivously Week 8 - AssignmentExpression: 8, - WhileStatement: 8, - // previously Week 9 - ForStatement: 9, - BreakStatement: 9, - ContinueStatement: 9, - MemberExpression: 9, // previously Week 10 - ThisExpression: 10, - ObjectExpression: 10, - Property: 10, - UpdateExpression: 10, NewExpression: 10, // Disallowed Forever SwitchStatement: Infinity, From 293f2498ef5c010f3020d9948c6c66f807c45d3c Mon Sep 17 00:00:00 2001 From: remo5000 Date: Mon, 30 Jul 2018 18:23:40 +0800 Subject: [PATCH 3/4] Set disableOn for some rules --- src/rules/noDeclareMutable.ts | 1 + src/rules/noNonEmptyList.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rules/noDeclareMutable.ts b/src/rules/noDeclareMutable.ts index 115054847..784a9e948 100644 --- a/src/rules/noDeclareMutable.ts +++ b/src/rules/noDeclareMutable.ts @@ -27,6 +27,7 @@ export class NoDeclareMutableError implements SourceError { const noDeclareMutable: Rule = { name: 'no-declare-mutable', + disableOn: 3, checkers: { VariableDeclaration(node: es.VariableDeclaration) { diff --git a/src/rules/noNonEmptyList.ts b/src/rules/noNonEmptyList.ts index d5b3b2512..b38d40935 100644 --- a/src/rules/noNonEmptyList.ts +++ b/src/rules/noNonEmptyList.ts @@ -24,7 +24,7 @@ export class NoNonEmptyListError implements SourceError { const noNonEmptyList: Rule = { name: 'no-non-empty-list', - disableOn: 9, + disableOn: 3, checkers: { ArrayExpression(node: es.ArrayExpression) { From 699f3bf32d71108a9fb9a272987e1496e6a93143 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Mon, 30 Jul 2018 18:23:52 +0800 Subject: [PATCH 4/4] Fix elaboration for noImplicitDeclareUndefined --- src/rules/noImplicitDeclareUndefined.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rules/noImplicitDeclareUndefined.ts b/src/rules/noImplicitDeclareUndefined.ts index 8c42d495d..502ecd5c9 100644 --- a/src/rules/noImplicitDeclareUndefined.ts +++ b/src/rules/noImplicitDeclareUndefined.ts @@ -22,7 +22,7 @@ export class NoImplicitDeclareUndefinedError implements SourceError { A variable declaration assigns a value to a name. For instance, to assign 20 to ${this.node.name}, you can write: - var ${this.node.name} = 20; + let ${this.node.name} = 20; ${this.node.name} + ${this.node.name}; // 40 `