Skip to content

Object.defineProperty with TypeError: value is not a function #886

@wszgrcy

Description

@wszgrcy

What happened

TypeError: value is not a function
    at <anonymous>

What you expected

run

Minimal reproduction

// failed
const __defProp = Object.defineProperty;
const __export = (target: Record<string, any>, all: Record<string, any>) => {
  for (let name in all) __defProp(target, name, { get: all[name], enumerable: true });
};
__export(
  {},
  {
    a: () => 1,
  },
);
// success
// const __export = (target: Record<string, any>, all: Record<string, any>) => {
//   for (let name in all) Object.defineProperty(target, name, { get: all[name], enumerable: true });
// };
// __export(
//   {},
//   {
//     a: () => 1,
//   },
// );

Environment

  • Perry version: 0.5.923
  • Host OS: win10
  • Target: native
  • Rust toolchain (if building from source):
  • Installed via: npm/winget

Diagnostic output

> perry-test@1.0.0 doctor
> perry doctor

Perry Doctor

Environment Checks
──────────────────
  ✓ perry version: 0.5.923
  ✓ update status: up to date
  ✓ clang (LLVM codegen): clang version 22.1.5 (https://github.com/llvm/llvm-project 5ea218a153f4d2f815b8244eab3e4b4ba5e00e6c)
  ✓ system linker (MSVC link.exe): C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\bin\Hostx64\x64\link.exe
  ✓ runtime library: C:\code\my-project\perry-test\node_modules\@perryts\perry-win32-x64\lib\perry_runtime.lib
  ✓ project config (perry.toml): found

All checks passed!

Anything else

The code above was automatically generated by esbuild during the build process. I trimmed it down to pinpoint the exact location.
Should we prioritize supporting structures generated by bundlers, given that many users are likely to encounter these same issues?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions