From f79cba22252686aaef87a9e12397ef2d78dfa181 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 22 Jul 2014 13:37:37 -0700 Subject: [PATCH] Type check the expression of the 'with' statement --- src/compiler/checker.ts | 1 + tests/baselines/reference/arrowFunctionContexts.errors.txt | 6 +++++- tests/baselines/reference/parserStrictMode14.errors.txt | 4 +++- tests/baselines/reference/parserWithStatement1.d.errors.txt | 4 +++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 47810bab1ce..ffe79d7b48c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5195,6 +5195,7 @@ module ts { } function checkWithStatement(node: WithStatement) { + checkExpression(node.expression); error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } diff --git a/tests/baselines/reference/arrowFunctionContexts.errors.txt b/tests/baselines/reference/arrowFunctionContexts.errors.txt index 37ff35cb23d..b768abb8575 100644 --- a/tests/baselines/reference/arrowFunctionContexts.errors.txt +++ b/tests/baselines/reference/arrowFunctionContexts.errors.txt @@ -1,9 +1,11 @@ -==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (8 errors) ==== +==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (10 errors) ==== // Arrow function used in with statement with (window) { ~~~~~~ !!! All symbols within a 'with' block will be resolved to 'any'. + ~~~~~~ +!!! Cannot find name 'window'. var p = () => this; } @@ -53,6 +55,8 @@ with (window) { ~~~~~~ !!! All symbols within a 'with' block will be resolved to 'any'. + ~~~~~~ +!!! Cannot find name 'window'. var p = () => this; } diff --git a/tests/baselines/reference/parserStrictMode14.errors.txt b/tests/baselines/reference/parserStrictMode14.errors.txt index 2f90123bb5c..2291ebd80b7 100644 --- a/tests/baselines/reference/parserStrictMode14.errors.txt +++ b/tests/baselines/reference/parserStrictMode14.errors.txt @@ -1,6 +1,8 @@ -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode14.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode14.ts (2 errors) ==== "use strict"; with (a) { ~ !!! All symbols within a 'with' block will be resolved to 'any'. + ~ +!!! Cannot find name 'a'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserWithStatement1.d.errors.txt b/tests/baselines/reference/parserWithStatement1.d.errors.txt index 1d71f990311..b56589d2e00 100644 --- a/tests/baselines/reference/parserWithStatement1.d.errors.txt +++ b/tests/baselines/reference/parserWithStatement1.d.errors.txt @@ -1,7 +1,9 @@ -==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement1.d.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement1.d.ts (3 errors) ==== with (foo) { ~~~~ !!! Statements are not allowed in ambient contexts. ~~~ !!! All symbols within a 'with' block will be resolved to 'any'. + ~~~ +!!! Cannot find name 'foo'. } \ No newline at end of file