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

those sneaky debugger statements make the compiler upset #4030

Closed
zpdDG4gta8XKpMCd opened this issue Jul 26, 2015 · 1 comment
Closed

those sneaky debugger statements make the compiler upset #4030

zpdDG4gta8XKpMCd opened this issue Jul 26, 2015 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@zpdDG4gta8XKpMCd
Copy link

function f1<r>(): r {
    throw new Error(String(Math.random())); // nothing to it so far
}

function f2<r>(): r {
    debugger;
    throw new Error(String(Math.random()));  // all hell breaks loose
}

live demo

@mhegazy
Copy link
Contributor

mhegazy commented Jul 26, 2015

looks like a dupe of #1042

As i mentioned in #3647 (comment):

This is because the compiler does not do control flow analysis at this point. it would be a restriction that can be relaxed once this support is added.

As for now this is by design, as per the section 6.3: function implementations from the language spec:

An explicitly typed function whose return type isn't the Void or the Any type must have at least one return statement somewhere in its body. An exception to this rule is if the function implementation consists of a single 'throw' statement.

@mhegazy mhegazy added the Duplicate An existing issue was already created label Jul 26, 2015
@mhegazy mhegazy closed this as completed Jul 26, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants