slint-ui/slint · warning

Duplicated function name

Error message

Duplicated function name ${functionName}

What it means

Declared public functions of a Slint component are exposed as callable JS methods on the Component wrapper. When the translated function name already exists on the object (collision with another function, callback, property, or built-in), the function is skipped and this warning is emitted. The function will not be callable under the expected JS name.

Solutions

  1. Rename one of the colliding functions in the .slint file
  2. Use the warning text to find the duplicate name in the .slint source and de-duplicate
  3. Fall back to calling the function through the raw instance API if renaming is blocked

Example fix

// before (file.slint)
function do-work() {}
public function doWork() {}
// after (file.slint)
public function do-work() {}
public function perform-task() {}
Defensive patterns

Strategy: validation

Validate before calling

const fnNames = definition.functions.map(translateName);
const dupes = fnNames.filter((n, i) => fnNames.indexOf(n) !== i);
if (dupes.length) throw new Error(`Duplicate function names: ${dupes}`);

Type guard

function callableExists(component, name) {
  return typeof component[name] === 'function';
}

Prevention

When it happens

Trigger: Calling loadFile() or loadSource() on a component with two public functions translating to the same JS name (e.g. 'do-work' and 'doWork'), or a function named like an existing Component member.

Common situations: Case-only duplicates introduced by edits or tooling; generated Slint code whose function names collide after kebab-to-camel translation.

Related errors


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/d43c282d3fca7c04. Report an issue: GitHub.

Appendix: source

Thrown at api/node/typescript/index.ts:479

                                            cb,
                                            Array.from(arguments),
                                        );
                                    };
                                },
                                set(callback) {
                                    instance!.setCallback(cb, callback);
                                },
                                enumerable: true,
                            },
                        );
                    }
                });

                instance!.definition().functions.forEach((cb) => {
                    const functionName = translateName(cb);

                    if (componentHandle[functionName] !== undefined) {
                        console.warn(
                            "Duplicated function name " + functionName,
                        );
                    } else {
                        Object.defineProperty(
                            componentHandle,
                            translateName(cb),
                            {
                                get() {
                                    return function () {
                                        return instance!.invoke(
                                            cb,
                                            Array.from(arguments),
                                        );
                                    };
                                },
                                enumerable: true,
                            },
                        );

View on GitHub (pinned to bb937076de)