{"record":{"id":"d9bd2ff06293298a","repo":"different-ai/openwork","slug":"string-name-expects-number-arguments","errorCode":null,"errorMessage":"String.${name} expects number arguments.","messagePattern":"String\\.(.+?) expects number arguments\\.","errorType":"exception","errorClass":"InterpreterRuntimeError","httpStatus":null,"severity":"error","filePath":"packages/codemode/src/stdlib/string.ts","lineNumber":40,"sourceCode":"  \"padEnd\",\n  \"charAt\",\n  \"charCodeAt\",\n  \"codePointAt\",\n  \"at\",\n  \"concat\",\n  \"toString\",\n  \"match\",\n  \"matchAll\",\n  \"search\",\n  \"localeCompare\",\n  \"normalize\",\n])\n\nexport const stringStatics = new Set([\"fromCharCode\", \"fromCodePoint\"])\n\nexport const invokeStringStatic = (name: string, args: Array<unknown>, node: AstNode): unknown => {\n  const codes = args.map((arg) => {\n    if (typeof arg !== \"number\") throw new InterpreterRuntimeError(`String.${name} expects number arguments.`, node)\n    return arg\n  })\n  switch (name) {\n    case \"fromCharCode\":\n      return String.fromCharCode(...codes)\n    case \"fromCodePoint\":\n      return String.fromCodePoint(...codes)\n    default:\n      throw new InterpreterRuntimeError(`String.${name} is not available in CodeMode.`, node)\n  }\n}\nimport { type AstNode, InterpreterRuntimeError } from \"../interpreter/model.js\"\n","sourceCodeStart":22,"sourceCodeEnd":53,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/packages/codemode/src/stdlib/string.ts#L22-L53","documentation":"String.fromCharCode and String.fromCodePoint require every argument to be a number (a char code / code point). CodeMode validates each argument before calling the host static and throws this error as soon as any argument is not a number.","triggerScenarios":"`String.fromCharCode(\"65\")`, `String.fromCodePoint(null)`, or an array spread of mixed/undefined values passed to either static.","commonSituations":"Data decoded from JSON keeps code points as strings; a code-point array contains undefined holes; accidental string/number confusion.","solutions":["Convert each argument with Number() before calling: `String.fromCharCode(Number(code))`.","Filter/validate the input array: `codes.filter(c => typeof c === \"number\")` then spread.","Fix the producer of the values to emit numbers.","For array input, use `...codes.map(Number)` only after validating all elements."],"exampleFix":"// before\nString.fromCharCode(...rawCodes) // rawCodes[1] is \"65\"\n// after\nString.fromCharCode(...rawCodes.map((c) => Number(c)))","handlingStrategy":"validation","validationCode":"const nums = args.map(Number)\nif (nums.some((n) => typeof n !== \"number\" || Number.isNaN(n))) throw new TypeError(\"all args must be numbers\")\nString.fromCharCode(...nums)","typeGuard":"const isNumberArray = (a) => Array.isArray(a) && a.every((x) => typeof x === \"number\")","tryCatchPattern":"try { s = String.fromCharCode(...codes) } catch (e) { s = \"\" }","preventionTips":["Coerce code arrays with map(Number) before spreading","Validate JSON payloads numerically at boundaries","Avoid undefined holes in sparse arrays used as code lists"],"tags":["codemode","string","type-error","sandbox"],"backgroundTag":"argument-type-mismatch","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}