diff --git a/.github/algorithm-format-check.mjs b/.github/algorithm-format-check.mjs index 592d721de..702c79411 100644 --- a/.github/algorithm-format-check.mjs +++ b/.github/algorithm-format-check.mjs @@ -2,6 +2,9 @@ import { readFile, readdir } from "node:fs/promises"; const SPEC_DIR = new URL("../spec", import.meta.url).pathname; +/** @see {@link https://spec-md.com/#sec-Value-Literals} */ +const valueLiteralsRegexp = /\{((?:[^{}]|(?:\{[^{}]*\}))+)\}/g; + process.exitCode = 0; const filenames = await readdir(SPEC_DIR); for (const filename of filenames) { @@ -72,6 +75,33 @@ for (const filename of filenames) { console.log(); process.exitCode = 1; } + + const stepWithoutValueLiterals = step.replace( + valueLiteralsRegexp, + "" + ); + if (stepWithoutValueLiterals.match(/\b[A-Z][A-Za-z0-9]+\(/)) { + console.log( + `Bad formatting of '${algorithmName}' step (algorithm call should be wrapped in braces: \`{MyAlgorithm(a, b, c)}\`) in '${filename}':` + ); + console.dir(step); + console.log(); + process.exitCode = 1; + } + + const valueLiterals = step.matchAll(valueLiteralsRegexp, ""); + for (const lit of valueLiterals) { + const inner = lit[1]; + if (inner.includes("{")) { + console.log( + `Bad formatting of '${algorithmName}' step (algorithm call should not contain braces: \`${lit}\`) in '${filename}':` + ); + console.dir(step); + console.log(); + process.exitCode = 1; + } + } + const trimmedInnerLine = step.replace(/\s+/g, " "); if ( trimmedInnerLine.match( diff --git a/spec/Section 3 -- Type System.md b/spec/Section 3 -- Type System.md index 04e4fa450..945c916f6 100644 --- a/spec/Section 3 -- Type System.md +++ b/spec/Section 3 -- Type System.md @@ -351,7 +351,7 @@ IsInputType(type): - If {type} is a List type or Non-Null type: - Let {unwrappedType} be the unwrapped type of {type}. - - Return IsInputType({unwrappedType}). + - Return {IsInputType(unwrappedType)}. - If {type} is a Scalar, Enum, or Input Object type: - Return {true}. - Return {false}. @@ -360,7 +360,7 @@ IsOutputType(type): - If {type} is a List type or Non-Null type: - Let {unwrappedType} be the unwrapped type of {type}. - - Return IsOutputType({unwrappedType}). + - Return {IsOutputType(unwrappedType)}. - If {type} is a Scalar, Object, Interface, Union, or Enum type: - Return {true}. - Return {false}.