mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-16 01:41:17 -06:00
fix(57386): Invalid use of 'eval' when defining a namespaced eval function (#57391)
This commit is contained in:
parent
5d17aa7eb9
commit
8ada4ef44f
@ -2563,7 +2563,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
}
|
||||
|
||||
function checkStrictModeFunctionName(node: FunctionLikeDeclaration) {
|
||||
if (inStrictMode) {
|
||||
if (inStrictMode && !(node.flags & NodeFlags.Ambient)) {
|
||||
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1))
|
||||
checkStrictModeEvalOrArguments(node, node.name);
|
||||
}
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
//// [tests/cases/compiler/evalOrArgumentsInDeclarationFunctions.ts] ////
|
||||
|
||||
=== /a.d.ts ===
|
||||
declare global {
|
||||
>global : Symbol(global, Decl(a.d.ts, 0, 0))
|
||||
|
||||
export namespace ns {
|
||||
>ns : Symbol(ns, Decl(a.d.ts, 0, 16))
|
||||
|
||||
export function eval(): void;
|
||||
>eval : Symbol(eval, Decl(a.d.ts, 1, 25))
|
||||
|
||||
export function arguments(): void;
|
||||
>arguments : Symbol(arguments, Decl(a.d.ts, 2, 37))
|
||||
}
|
||||
}
|
||||
|
||||
declare function eval(): void;
|
||||
>eval : Symbol(eval, Decl(a.d.ts, 5, 1))
|
||||
|
||||
declare function arguments(): void;
|
||||
>arguments : Symbol(arguments, Decl(a.d.ts, 7, 30))
|
||||
|
||||
export {}
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
//// [tests/cases/compiler/evalOrArgumentsInDeclarationFunctions.ts] ////
|
||||
|
||||
=== /a.d.ts ===
|
||||
declare global {
|
||||
>global : typeof global
|
||||
|
||||
export namespace ns {
|
||||
>ns : typeof ns
|
||||
|
||||
export function eval(): void;
|
||||
>eval : () => void
|
||||
|
||||
export function arguments(): void;
|
||||
>arguments : () => void
|
||||
}
|
||||
}
|
||||
|
||||
declare function eval(): void;
|
||||
>eval : () => void
|
||||
|
||||
declare function arguments(): void;
|
||||
>arguments : () => void
|
||||
|
||||
export {}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
// @filename: /a.d.ts
|
||||
declare global {
|
||||
export namespace ns {
|
||||
export function eval(): void;
|
||||
export function arguments(): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare function eval(): void;
|
||||
declare function arguments(): void;
|
||||
|
||||
export {}
|
||||
Loading…
x
Reference in New Issue
Block a user