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

Hash context module uses digit as loop variable #58

Closed
Siorki opened this issue Nov 15, 2016 · 2 comments
Closed

Hash context module uses digit as loop variable #58

Siorki opened this issue Nov 15, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@Siorki
Copy link
Owner

Siorki commented Nov 15, 2016

Issue obtained on benchmark file 2016 - Voxeling.js with settings :

	withMath : false,
	hash2DContext : true,
	hashWebGLContext : true,
	hashAudioContext : true,
	contextVariableName : 'c',
	contextType : 0,
	reassignVars : true,
	varsNotReassigned : 'abcdg',
	crushGainFactor : 1.0,
	crushLengthFactor : 0.0,
	crushCopiesFactor : 0.0,
	crushTiebreakerFactor : 1,
	wrapInSetInterval : false,
	timeVariableName : ""

The hashing loop uses 2 as variable for both 2D names and 2D properties :

for(2 in c)c[2[2]+[2[5]]]=c[2];
for(2 in c)c[2[0]+[2[6]]]=2;

Of course the resulting code does not work.
The reason for that behavior is that the original code contains for(2==m so 2 is considered as a potential loop variable, along with k, p and s, and the first one in ASCII order is chosen.

@Siorki Siorki added the bug label Nov 15, 2016
@Siorki Siorki added this to the 5.0 milestone Nov 15, 2016
@Siorki Siorki self-assigned this Nov 15, 2016
@Siorki
Copy link
Owner Author

Siorki commented Nov 15, 2016

Solution : change the RegExp that matches for(variable to only consider valid variable names (no digits).

Siorki added a commit that referenced this issue Nov 25, 2016
@Siorki
Copy link
Owner Author

Siorki commented Nov 25, 2016

Replaced \w in regex by [A-Za-z$_]

@Siorki Siorki closed this as completed Nov 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant