Skip to content
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

Simple control flow analysis #1287

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(co

var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
var servicesDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), [copyright], /*useBuiltCompiler:*/ true, /*noOutFile:*/ false, /*generateDeclarations:*/ true);
compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), [copyright], /*useBuiltCompiler:*/ false, /*noOutFile:*/ false, /*generateDeclarations:*/ true);

// Local target to build the compiler and services
desc("Builds the full compiler and services");
Expand Down
5 changes: 3 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/// <reference path="parser.ts"/>
/// <reference path="binder.ts"/>
/// <reference path="emitter.ts"/>
/// <reference path="controlflow.ts"/>
Copy link
Member

Choose a reason for hiding this comment

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

Consider controlFlow.ts, but I like this too.


module ts {
var nextSymbolId = 1;
Expand Down Expand Up @@ -6150,7 +6151,7 @@ module ts {

function checkFunctionExpressionBody(node: FunctionExpression) {
if (node.type) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
checkControlFlowOfFunction(node, getTypeFromTypeNode(node.type) !== voidType, error);
}
if (node.body.kind === SyntaxKind.FunctionBlock) {
checkSourceElement(node.body);
Expand Down Expand Up @@ -7294,7 +7295,7 @@ module ts {

checkSourceElement(node.body);
if (node.type && !isAccessor(node.kind)) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
checkControlFlowOfFunction(node, getTypeFromTypeNode(node.type) !== voidType, error);
}

// If there is no body and no explicit return type, then report an error.
Expand Down
Loading