From 299f1c3390e2a1fcaa75b8cae78c4b3e7c29bbc6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 25 Jul 2014 11:01:09 -0700 Subject: [PATCH 1/2] Properly set exit code for process. Supercedes #246. Includes provisions for buggy behavior of WScript.Quit. --- src/compiler/sys.ts | 6 +++++- src/compiler/tc.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 5215617d5f1..51fe9214e71 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -125,7 +125,11 @@ var sys: System = (function () { return 0; }, exit(exitCode?: number): void { - WScript.Quit(exitCode); + try { + WScript.Quit(exitCode); + } + catch (e) { + } } }; } diff --git a/src/compiler/tc.ts b/src/compiler/tc.ts index 0de66b58572..d44d1b9724c 100644 --- a/src/compiler/tc.ts +++ b/src/compiler/tc.ts @@ -227,4 +227,4 @@ module ts { } } -ts.executeCommandLine(sys.args); +sys.exit(ts.executeCommandLine(sys.args)); From aa40dc59b11e09db998013c9b3134957324a35fe Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 25 Jul 2014 13:39:11 -0700 Subject: [PATCH 2/2] Fix up comment about bug #236 in checkCallExpression --- src/compiler/checker.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9f1b0abaecf..12d6d32e1ad 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3832,16 +3832,15 @@ module ts { // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var signatures = getSignaturesOfType(apparentType, SignatureKind.Call); + var callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); var constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct); // TS 1.0 spec: 4.12 - // If FuncExpr is of type Any, or of an object type that has no call signatures but is a - // subtype of the Function interface, the call is an untyped function call. In an untyped - // function call no TypeArgs are permitted, Args can be any argument list, no contextual + // If FuncExpr is of type Any, or of an object type that has no call or construct signatures + // but is a subtype of the Function interface, the call is an untyped function call. In an + // untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. - // NOTE (not in spec yet): permit untyped call only if type has no both call and construct signatures - if ((funcType === anyType) || (!signatures.length && !constructSignatures.length && isTypeAssignableTo(funcType, globalFunctionType))) { + if ((funcType === anyType) || (!callSignatures.length && !constructSignatures.length && isTypeAssignableTo(funcType, globalFunctionType))) { if (node.typeArguments) { error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); } @@ -3850,7 +3849,7 @@ module ts { // If FuncExpr's apparent type(section 3.8.1) is a function type, the call is a typed function call. // TypeScript employs overload resolution in typed function calls in order to support functions // with multiple call signatures. - if (!signatures.length) { + if (!callSignatures.length) { if (constructSignatures.length) { error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); } @@ -3859,7 +3858,7 @@ module ts { } return checkErrorCall(node); } - return checkCall(node, signatures); + return checkCall(node, callSignatures); } function checkNewExpression(node: NewExpression): Type {