Skip to content

function pointers with some names may couse to endless compilation #1652

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

Closed
MaxGraey opened this issue Jan 31, 2021 · 2 comments · Fixed by #1666
Closed

function pointers with some names may couse to endless compilation #1652

MaxGraey opened this issue Jan 31, 2021 · 2 comments · Fixed by #1666
Labels

Comments

@MaxGraey
Copy link
Member

MaxGraey commented Jan 31, 2021

example:

export function test(): void {
  function fnDecl(val: i32): i32 {
    return val;
  }

  const exprDecl = function fnDecl(val: i64): i64 { // <- fnDecl function name
    return val;
  }

  const fn32 = [fnDecl];
  const fn64 = [exprDecl];
}

this cause to error:

export function test(): void {
  function fnDecl(val: i32): i32 {
    return val;
  }

  const exprDecl = function (val: i64): i64 {
    return val;
  }

  const fn32 = [fnDecl];
  const fn64 = [exprDecl];
}

output:

ERROR TS2304: Cannot find name 'fnDecl'.
;; 
;;    const fn32 = [fnDecl];
;;                  ~~~~~~
@MaxGraey MaxGraey changed the title function pointer may couse to endless compilation function pointers may couse to endless compilation Jan 31, 2021
@dcodeIO
Copy link
Member

dcodeIO commented Jan 31, 2021

I believe inner functions are currently always anonymous, explaining the error. Does the endless loop happen after the error?

@MaxGraey
Copy link
Member Author

MaxGraey commented Jan 31, 2021

endless loop caused by this line: const exprDecl = function fnDecl(val: i64): i64. If you change fnDecl to something else it pass and will throw error as below (second example). So second fnDecl should be shadowed I guess. But exprDecl and fnDecl should create different pointers

@MaxGraey MaxGraey changed the title function pointers may couse to endless compilation function pointers with some names may couse to endless compilation Feb 1, 2021
@dcodeIO dcodeIO added the bug label Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants