-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore self tail calls when collecting the return type of a function (#…
- Loading branch information
1 parent
6afe257
commit e9cbebb
Showing
14 changed files
with
377 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
tests/baselines/reference/recursiveGenericSignatureInstantiation.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
=== tests/cases/compiler/recursiveGenericSignatureInstantiation.ts === | ||
function f6<T>(x: T) { | ||
>f6 : <T>(x: T) => any | ||
>f6 : <T>(x: T) => never | ||
>x : T | ||
|
||
return f6(x); | ||
>f6(x) : any | ||
>f6 : <T>(x: T) => any | ||
>f6(x) : never | ||
>f6 : <T>(x: T) => never | ||
>x : T | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
tests/baselines/reference/simpleRecursionWithBaseCase.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
tests/cases/compiler/simpleRecursionWithBaseCase.ts(8,21): error TS2554: Expected 1 arguments, but got 0. | ||
tests/cases/compiler/simpleRecursionWithBaseCase.ts(13,20): error TS2554: Expected 1 arguments, but got 0. | ||
tests/cases/compiler/simpleRecursionWithBaseCase.ts(19,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. | ||
tests/cases/compiler/simpleRecursionWithBaseCase.ts(27,16): error TS2304: Cannot find name 'notfoundsymbol'. | ||
tests/cases/compiler/simpleRecursionWithBaseCase.ts(31,10): error TS7023: 'fn5' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. | ||
|
||
|
||
==== tests/cases/compiler/simpleRecursionWithBaseCase.ts (5 errors) ==== | ||
function fn1(n: number) { | ||
if (n === 0) { | ||
return 3; | ||
} else { | ||
return fn1(n - 1); | ||
} | ||
} | ||
const num: number = fn1(); | ||
~~~~~ | ||
!!! error TS2554: Expected 1 arguments, but got 0. | ||
!!! related TS6210 tests/cases/compiler/simpleRecursionWithBaseCase.ts:1:14: An argument for 'n' was not provided. | ||
|
||
function fn2(n: number) { | ||
return fn2(n); | ||
} | ||
const nev: never = fn2(); | ||
~~~~~ | ||
!!! error TS2554: Expected 1 arguments, but got 0. | ||
!!! related TS6210 tests/cases/compiler/simpleRecursionWithBaseCase.ts:10:14: An argument for 'n' was not provided. | ||
|
||
function fn3(n: number) { | ||
if (n === 0) { | ||
return 3; | ||
} else { | ||
return fn1("hello world"); | ||
~~~~~~~~~~~~~ | ||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. | ||
} | ||
} | ||
|
||
function fn4(n: number) { | ||
if (n === 0) { | ||
return 3; | ||
} else { | ||
return notfoundsymbol("hello world"); | ||
~~~~~~~~~~~~~~ | ||
!!! error TS2304: Cannot find name 'notfoundsymbol'. | ||
} | ||
} | ||
|
||
function fn5() { | ||
~~~ | ||
!!! error TS7023: 'fn5' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. | ||
return [fn5][0](); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//// [simpleRecursionWithBaseCase.ts] | ||
function fn1(n: number) { | ||
if (n === 0) { | ||
return 3; | ||
} else { | ||
return fn1(n - 1); | ||
} | ||
} | ||
const num: number = fn1(); | ||
|
||
function fn2(n: number) { | ||
return fn2(n); | ||
} | ||
const nev: never = fn2(); | ||
|
||
function fn3(n: number) { | ||
if (n === 0) { | ||
return 3; | ||
} else { | ||
return fn1("hello world"); | ||
} | ||
} | ||
|
||
function fn4(n: number) { | ||
if (n === 0) { | ||
return 3; | ||
} else { | ||
return notfoundsymbol("hello world"); | ||
} | ||
} | ||
|
||
function fn5() { | ||
return [fn5][0](); | ||
} | ||
|
||
|
||
//// [simpleRecursionWithBaseCase.js] | ||
"use strict"; | ||
function fn1(n) { | ||
if (n === 0) { | ||
return 3; | ||
} | ||
else { | ||
return fn1(n - 1); | ||
} | ||
} | ||
var num = fn1(); | ||
function fn2(n) { | ||
return fn2(n); | ||
} | ||
var nev = fn2(); | ||
function fn3(n) { | ||
if (n === 0) { | ||
return 3; | ||
} | ||
else { | ||
return fn1("hello world"); | ||
} | ||
} | ||
function fn4(n) { | ||
if (n === 0) { | ||
return 3; | ||
} | ||
else { | ||
return notfoundsymbol("hello world"); | ||
} | ||
} | ||
function fn5() { | ||
return [fn5][0](); | ||
} |
65 changes: 65 additions & 0 deletions
65
tests/baselines/reference/simpleRecursionWithBaseCase.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
=== tests/cases/compiler/simpleRecursionWithBaseCase.ts === | ||
function fn1(n: number) { | ||
>fn1 : Symbol(fn1, Decl(simpleRecursionWithBaseCase.ts, 0, 0)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase.ts, 0, 13)) | ||
|
||
if (n === 0) { | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase.ts, 0, 13)) | ||
|
||
return 3; | ||
} else { | ||
return fn1(n - 1); | ||
>fn1 : Symbol(fn1, Decl(simpleRecursionWithBaseCase.ts, 0, 0)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase.ts, 0, 13)) | ||
} | ||
} | ||
const num: number = fn1(); | ||
>num : Symbol(num, Decl(simpleRecursionWithBaseCase.ts, 7, 5)) | ||
>fn1 : Symbol(fn1, Decl(simpleRecursionWithBaseCase.ts, 0, 0)) | ||
|
||
function fn2(n: number) { | ||
>fn2 : Symbol(fn2, Decl(simpleRecursionWithBaseCase.ts, 7, 26)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase.ts, 9, 13)) | ||
|
||
return fn2(n); | ||
>fn2 : Symbol(fn2, Decl(simpleRecursionWithBaseCase.ts, 7, 26)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase.ts, 9, 13)) | ||
} | ||
const nev: never = fn2(); | ||
>nev : Symbol(nev, Decl(simpleRecursionWithBaseCase.ts, 12, 5)) | ||
>fn2 : Symbol(fn2, Decl(simpleRecursionWithBaseCase.ts, 7, 26)) | ||
|
||
function fn3(n: number) { | ||
>fn3 : Symbol(fn3, Decl(simpleRecursionWithBaseCase.ts, 12, 25)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase.ts, 14, 13)) | ||
|
||
if (n === 0) { | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase.ts, 14, 13)) | ||
|
||
return 3; | ||
} else { | ||
return fn1("hello world"); | ||
>fn1 : Symbol(fn1, Decl(simpleRecursionWithBaseCase.ts, 0, 0)) | ||
} | ||
} | ||
|
||
function fn4(n: number) { | ||
>fn4 : Symbol(fn4, Decl(simpleRecursionWithBaseCase.ts, 20, 1)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase.ts, 22, 13)) | ||
|
||
if (n === 0) { | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase.ts, 22, 13)) | ||
|
||
return 3; | ||
} else { | ||
return notfoundsymbol("hello world"); | ||
} | ||
} | ||
|
||
function fn5() { | ||
>fn5 : Symbol(fn5, Decl(simpleRecursionWithBaseCase.ts, 28, 1)) | ||
|
||
return [fn5][0](); | ||
>fn5 : Symbol(fn5, Decl(simpleRecursionWithBaseCase.ts, 28, 1)) | ||
} | ||
|
Oops, something went wrong.