Skip to content

Commit

Permalink
Fixes for shouldNotDuplicateGlobalDefinitions
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Dec 6, 2023
1 parent 2da6f7d commit a9fbbca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ const error = problem('error')
// VALIDATION MESSAGES
// ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

const valuesForNodeName = (node: { name: string}) => [node.name ?? '']
const valuesForNodeName = (node: { name?: string }) => [node.name ?? '']

const sourceMapForNodeName = (node: Node & { name: string }) => {
const sourceMapForNodeName = (node: Node & { name?: string }) => {
if (!node.sourceMap) return undefined
const nodeOffset = getOffsetForName(node)
return node.sourceMap && new SourceMap({
Expand Down Expand Up @@ -125,7 +125,7 @@ export const nameShouldBeginWithLowercase = nameMatches(/^[a-z_<]/)

export const nameShouldNotBeKeyword = error<Parameter | Variable | Field | Method>(node =>
!RESERVED_WORDS.includes(node.name || ''),
node => [node.name ?? ''],
valuesForNodeName,
sourceMapForNodeName,
)

Expand Down Expand Up @@ -299,7 +299,9 @@ export const parameterShouldNotDuplicateExistingVariable = error<Parameter>(node
export const shouldNotDuplicateLocalVariables = error<Variable>(node => !duplicatesLocalVariable(node), valuesForNodeName, sourceMapForNodeName)

export const shouldNotDuplicateGlobalDefinitions = error<Module | Variable>(node =>
!node.name || !node.parent.is(Package) || isEmpty(node.siblings().filter(child => (child as Entity).name == node.name))
!node.name || !node.parent.is(Package) || isEmpty(node.siblings().filter(child => (child as Entity).name == node.name)),
valuesForNodeName,
sourceMapForNodeName,
)

export const shouldNotDuplicateVariablesInLinearization = error<Module>(node => {
Expand Down

0 comments on commit a9fbbca

Please sign in to comment.