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

Incorrect output when using print with an array #4143

Closed
3 of 17 tasks
nonsequitoria opened this issue Nov 13, 2019 · 4 comments
Closed
3 of 17 tasks

Incorrect output when using print with an array #4143

nonsequitoria opened this issue Nov 13, 2019 · 4 comments

Comments

@nonsequitoria
Copy link

nonsequitoria commented Nov 13, 2019

Nature of issue?

  • Found a bug
  • Existing feature enhancement
  • New feature request

Most appropriate sub-area of p5.js?

  • Color
  • Core/Environment/Rendering
  • Data
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

Which platform were you using when you encountered this?

  • Mobile/Tablet (touch devices)
  • Desktop/Laptop
  • Others (specify if possible)

Details about the bug:

  • p5.js version: 0.9.0

  • Web browser and version: Google Chrome | 78.0.3904.97 (Official Build) (64-bit)

  • Operating System: MacOSX

  • Steps to reproduce this:

function setup() {
  let a = [1, 2];
  print(a); // should print [1, 2] but actually prints [3, 2] 
  print(a[0]); // correctly prints 1
  a[0] = 3;
  print(a); // correctly prints [3, 2]
  print(a[0]); // correctly prints 3  
}
@welcome
Copy link

welcome bot commented Nov 13, 2019

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

@anuragakella
Copy link

Not sure why that's happening for you? Seems to be working fine for me...

Check this out:
[used the exact same code that you used]
https://codepen.io/anuragakella/pen/NWWOxKj?editors=1111

@nonsequitoria
Copy link
Author

Thanks for the test @anuragakella. Note your example is using p5.js version: 0.7.1, but I checked it on CodePen with version 0.9.0, and it also works as expected.

So, I think this might be related to the p5 web editor. It must handle console output or how the code is run in some non-standard way. Try running my test code there: https://editor.p5js.org/nonsequitoria/sketches/6MS3iYNJG

@lmccart
Copy link
Member

lmccart commented Nov 14, 2019

closing this because it's covered in processing/p5.js-web-editor#1203

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

No branches or pull requests

3 participants