mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-19 00:31:06 +00:00
Merge commit '6e92d2345e8231a44556ce7d416451f5f3e6c398' as 'engine262'
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import type { ParseNode } from '../parser/ParseNode.mts';
|
||||
import { HasInitializer } from './all.mts';
|
||||
|
||||
export function ExpectedArgumentCount(FormalParameterList: ParseNode.FormalParameters) {
|
||||
if (FormalParameterList.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
for (const FormalParameter of FormalParameterList.slice(0, -1)) {
|
||||
const BindingElement = FormalParameter;
|
||||
if (HasInitializer(BindingElement)) {
|
||||
return count;
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
|
||||
const last = FormalParameterList[FormalParameterList.length - 1];
|
||||
if (last.type === 'BindingRestElement') {
|
||||
return count;
|
||||
}
|
||||
if (HasInitializer(last)) {
|
||||
return count;
|
||||
}
|
||||
return count + 1;
|
||||
}
|
||||
Reference in New Issue
Block a user