Skip to content

Strict mode support #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jul 24, 2014
Merged

Strict mode support #217

merged 20 commits into from
Jul 24, 2014

Conversation

vladima
Copy link
Contributor

@vladima vladima commented Jul 23, 2014

fixes #129 and #130

@@ -99,6 +99,7 @@ module ts {
A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: DiagnosticCategory.Error, key: "A constructor implementation cannot be declared in an ambient context." },
A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional." },
A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." },
Object_literal_cannot_contain_more_than_one_property_with_the_same_name_in_the_strict_mode: { code: 1114, category: DiagnosticCategory.Error, key: "Object literal cannot contain more than one property with the same name in the strict mode." },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't say "in the strict mode". that sounds wrong.

@vladima
Copy link
Contributor Author

vladima commented Jul 24, 2014

@CyrusNajmabadi any other comments?

if (isPrologueDirective(element)) {
if (isUseStrictPrologueDirective(element)) {
isInStrictMode = true;
checkForStrictMode = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's correct to set the checkForStrictMode flag here. See http://www.ecma-international.org/ecma-262/5.1/#sec-14.1 -- the directive prologue consists of all the leading string literal expression statements, of which any might be "use strict"

e.g. this code snippet is strict mode and should error:

function foo() {
     "extra awesome";
     "use strict";
    var static = 0;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RyanCavanaugh and it will error. checkForStrictMode just denotes whether element needs to be tested to be directive. Code will iterate through all directives, once 'use strict' is found - global isInStrictMode flag will be set to true and checkForStrictMode - to false to skip checking other elements

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misread the else structure. 👍

@vladima
Copy link
Contributor Author

vladima commented Jul 24, 2014

fixes #129 and #130

@vladima vladima closed this Jul 24, 2014
@vladima vladima reopened this Jul 24, 2014
@danquirk
Copy link
Member

Sourcemap failures are likely newline related. You may need to re-base against master to get the Linux related test fixes?

vladima added a commit that referenced this pull request Jul 24, 2014
@vladima vladima merged commit a490eb2 into master Jul 24, 2014
@vladima vladima deleted the strict_mode branch August 3, 2014 05:40
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Errors] strict mode issues
6 participants