Closed
Description
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]);
}
}
Metadata
Metadata
Assignees
Type
Projects
Status
Completed