{"record":{"id":"d18e257e6b012b53","repo":"slint-ui/slint","slug":"duplicated-function-name-cb-on-global-global","errorCode":null,"errorMessage":"Duplicated function name ${cb} on global ${global}","messagePattern":"Duplicated function name (.+?) on global (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"api/node/typescript/index.ts","lineNumber":599,"sourceCode":"                                                    globalName,\n                                                    cb,\n                                                    callback,\n                                                );\n                                            },\n                                            enumerable: true,\n                                        },\n                                    );\n                                }\n                            });\n\n                        instance!\n                            .definition()\n                            .globalFunctions(globalName)\n                            ?.forEach((cb) => {\n                                const functionName = translateName(cb);\n\n                                if (globalObject[functionName] !== undefined) {\n                                    console.warn(\n                                        \"Duplicated function name \" +\n                                            cb +\n                                            \" on global \" +\n                                            global,\n                                    );\n                                } else {\n                                    Object.defineProperty(\n                                        globalObject,\n                                        translateName(cb),\n                                        {\n                                            get() {\n                                                return function () {\n                                                    return instance!.invokeGlobal(\n                                                        globalName,\n                                                        cb,\n                                                        Array.from(arguments),\n                                                    );\n                                                };","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/api/node/typescript/index.ts#L581-L617","documentation":"Public functions declared on an exported global are exposed as callable methods on the global's JS object. If the translated function name already exists on that object (collision with another function, callback, or property of the same global), the function is skipped and this warning is printed. The function will not be callable under the expected JS name.","triggerScenarios":"Calling loadFile() or loadSource() on a project where a global declares two functions translating to the same JS name, or a function named like an existing member of the same global.","commonSituations":"Case-only duplicates in global function names; a function whose name collides with a callback or property of the same global after kebab-to-camelCase translation.","solutions":["Rename the colliding function inside the global's .slint declaration","Use the warning text to find the duplicate in that global's code and de-duplicate","Call the function through the raw instance's global function API if renaming is not feasible"],"exampleFix":"// before (file.slint)\nexport global Calc {\n    public function compute(x: int) -> int;\n    public function compute(x: length) -> length; // collides after translation\n}\n// after (file.slint)\nexport global Calc {\n    public function compute-int(x: int) -> int;\n    public function compute-length(x: length) -> length;\n}","handlingStrategy":"validation","validationCode":"const fnNames = globalFunctions.map(translateName);\nconst dupes = fnNames.filter((n, i) => fnNames.indexOf(n) !== i);\nif (dupes.length) throw new Error(`Duplicate functions on global: ${dupes}`);","typeGuard":"function globalFunctionCallable(globalObj, name) {\n  return typeof globalObj[name] === 'function';\n}","tryCatchPattern":null,"preventionTips":["Keep global function names unique among functions, callbacks, and properties","Avoid relying on argument types to overload names — Slint translation will collide them","Lint globals for duplicate translated identifiers"],"tags":["nodejs","typescript","globals","naming-collision"],"backgroundTag":"invalid-identifier","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}