Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[p5.js 2.0 Beta Bug Report]: Error in FES prevents message from being shown #7678

Open
1 of 17 tasks
quinton-ashley opened this issue Mar 28, 2025 · 1 comment
Open
1 of 17 tasks

Comments

@quinton-ashley
Copy link
Contributor

quinton-ashley commented Mar 28, 2025

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

v2 beta 5

Web browser and version

134.0.6998.166 (Official Build) (arm64)

Operating system

macOS Version 15.3.2 (Build 24D81)

Steps to reproduce this

To reproduce run new p5().

Error log:

p5.js:74778 Uncaught TypeError: func.substring is not a function
    at mapToReference (p5.js:74778:34)
    at p5._report (p5.js:74821:19)
    at p5._friendlyError (p5.js:74859:12)
    at checkForUserDefinedFunctions (p5.js:74989:16)
mapToReference @ p5.js:74778
p5._report @ p5.js:74821
p5._friendlyError @ p5.js:74859
checkForUserDefinedFunctions @ p5.js:74989
p5.js:68523 Uncaught TypeError: Cannot read properties of undefined (reading 'pixels')
    at get pixels (p5.js:68523:29)
    at p5.js:75668:27
    at Array.map (<anonymous>)
    at getSymbols (p5.js:75665:12)
    at defineMisusedAtTopLevelCode (p5.js:75680:9)
    at helpForMisusedAtTopLevelCode (p5.js:75713:9)
get pixels @ p5.js:68523
(anonymous) @ p5.js:75668
getSymbols @ p5.js:75665
defineMisusedAtTopLevelCode @ p5.js:75680
helpForMisusedAtTopLevelCode @ p5.js:75713
p5.js:74778 Uncaught TypeError: func.substring is not a function
    at mapToReference (p5.js:74778:34)
    at p5._report (p5.js:74821:19)
    at p5._friendlyError (p5.js:74859:12)
    at checkForUserDefinedFunctions (p5.js:74989:16)
mapToReference @ p5.js:74778
p5._report @ p5.js:74821
p5._friendlyError @ p5.js:74859
checkForUserDefinedFunctions @ p5.js:74989
p5.js:68523 Uncaught TypeError: Cannot read properties of undefined (reading 'pixels')
    at get pixels (p5.js:68523:29)
    at p5.js:75668:27
    at Array.map (<anonymous>)
    at getSymbols (p5.js:75665:12)
    at defineMisusedAtTopLevelCode (p5.js:75680:9)
    at helpForMisusedAtTopLevelCode (p5.js:75713:9)
get pixels @ p5.js:68523
(anonymous) @ p5.js:75668
getSymbols @ p5.js:75665
defineMisusedAtTopLevelCode @ p5.js:75680
helpForMisusedAtTopLevelCode @ p5.js:75713

This error happens here in p5.js because context is the window and p5 overrides window.constructor p5's class constructor, which is why it's enumerated by Object.keys when it wouldn't otherwise.

fxns has a constructor property too because all JS Objects do, but ofc it doesn't store a string. Hence since func is not a string it lacks string methods.

for (const prop of Object.keys(context)) {
  const lowercase = prop.toLowerCase();

  // check if the lowercase property name has an entry in fxns, if the
  // actual name with correct capitalization doesnt exist in context,
  // and if the user-defined symbol is of the type function
  if (
    fxns[lowercase] &&
    !context[fxns[lowercase]] &&
    typeof context[prop] === 'function'
  ) {
    const msg = translator('fes.checkUserDefinedFns', {
      name: prop,
      actualName: fxns[lowercase]
    });

    p5._friendlyError(msg, fxns[lowercase]);
  }
}
@HughJacks
Copy link

Hi, I am wondering if anyone is working on this issue, and if i could be assigned to it.

Fair warning this is my first contribution. I would like to contribute as part of an assignment for coursework, but could not find any good first issues that were not either, trivial frontend code or already assigned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants