Conversation
| if ( | ||
| callee.type === 'MemberExpression' && | ||
| callee.property?.type === 'Identifier' && | ||
| callee.property.name === 'modify' |
There was a problem hiding this comment.
Do you think we should add a condition to this checking that the .modify() is called on a base*Shader call? Just thinking that modify on its own may be a bit too far-reaching
davepagurek
left a comment
There was a problem hiding this comment.
Nice work on this! Just one minor case I left a comment for, after that itll be good to go!
|
|
||
| for (let { name, line } of allDefinitions) { | ||
| if (!ignoreFunction.includes(name) && globalFunctions.has(name)) { | ||
| if (!ignoreFunction.includes(name) && globalFunctions.has(name) && !Object.hasOwn(builtInGLSLFunctions, name)) { |
There was a problem hiding this comment.
I think the !Object.hasOwn(builtInGLSLFunctions, name) guard here causes a regression. Names like max, floor, sin, abs, sqrt are both p5 globals and GLSL builtins, so with this guard a top-level function max() {} outside of any strands callback no longer triggers the existing p5 conflict warning (it did on main), and the new strands loop below skips it too since insideStrands is false.
So, we can remove this !Object.hasOwn(builtInGLSLFunctions, name), wdyt?
There was a problem hiding this comment.
hmm. removing it will make warning appear for common functions but will cause warnings for strands identifers like length used outside strands block... lemme think
There was a problem hiding this comment.
@perminder-17 we can create a new variable to store strandsAddedP5Globals, names strands adds to p5.prototype but were not original p5 globals. then skip only those in loop 1, so outside length stays silent while outside max still warns. loop 2 keeps the full builtin list, so inside max and length both warn. what do you think?
earlier i thought of using this pattern (const isp5Function = overrides[0].isp5Function;) used in src/strands/strands_api.js but then i realized that flag does not mean the same thing. It means p5 has something similar, not the same name on (eg, for distance its true but p5 has dist not distance)
…com/skyash-dev/p5.js into fix/fes-warnings-glsl-keywords-9038
Resolves #9038
Changes:
isStrandsBuildersCall.strandsBodyRangesusingrecordCallbackBody.isInsideStrands.insideStrandsin variables and functions ofuserDefinitions.builtInGLSLFunctionskeywords usedinsideStrands.test/unit/core/sketch_overrides.js.PR Checklist
npm run lint passes
Inline reference is included / updated
Unit tests are included / updated