From 0f0b19c6027e289f5fdce039ebabf52ee3cc9fc8 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 2 Jun 2023 09:37:41 -0300 Subject: infra: early error when relation() called w/ unlisted dependency --- src/content-function.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/content-function.js b/src/content-function.js index 921b5bcd..3536d5a8 100644 --- a/src/content-function.js +++ b/src/content-function.js @@ -219,6 +219,8 @@ export function getRelationsTree(dependencies, contentFunctionName, wikiData, .. return null; } + const listedDependencies = new Set(contentFunction.contentDependencies); + // TODO: Evaluating a sprawl might belong somewhere better than here, lol... const sprawl = (contentFunction.sprawl @@ -233,6 +235,10 @@ export function getRelationsTree(dependencies, contentFunctionName, wikiData, .. })(); const relationFunction = (name, ...args) => { + if (!listedDependencies.has(name)) { + throw new Error(`Called relation('${name}') but ${contentFunctionName} doesn't list that dependency`); + } + const relationSymbol = Symbol(relationSymbolMessage(name)); relationSlots[relationSymbol] = {name, args}; return {[relationIdentifier]: relationSymbol}; -- cgit 1.3.0-6-gf8a5