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

Worksheet doesn't show correct Array Output #6499

Closed
Leon0402 opened this issue Jun 12, 2024 · 6 comments · Fixed by #6523
Closed

Worksheet doesn't show correct Array Output #6499

Leon0402 opened this issue Jun 12, 2024 · 6 comments · Fixed by #6523
Labels
worksheets Use for tickets related to worksheets
Milestone

Comments

@Leon0402
Copy link

Describe the bug

Creating an array in a worksheet, outputs (part) of the object reference instead of the values:
image
As you can see with ArrayBuffer the output is as expected, while with fixed arrays object references are shown instead of values. And only a single, the rest is cutt off (hovering doesn't reveal more either).

I'm rather new to scala, but I don't think this is expected. It is certainly not what the REPL does.

Expected behavior

No response

Operating system

Linux

Editor/Extension

VS Code

Version of Metals

v1.3.1

Extra context or search terms

No response

@Leon0402 Leon0402 changed the title Worksheet doesn't show Arrays completly Worksheet doesn't show correct Array Output Jun 12, 2024
@tgodzik tgodzik added bug Something that is making a piece of functionality unusable upstream-fix-needed Waiting on a fix upstream worksheets Use for tickets related to worksheets labels Jun 12, 2024
@tgodzik
Copy link
Contributor

tgodzik commented Jun 12, 2024

Thanks for reporting! This one looks like another issue with mdoc.

@Leon0402
Copy link
Author

Leon0402 commented Jun 12, 2024

I assume it is using the toString method, which yields exactly that result in the REPL.

@tgodzik
Copy link
Contributor

tgodzik commented Jun 12, 2024

Ach, actually it's a special mechanism, which usually looks a bit better than normal toString, but we seem to have a bug here.

@tgodzik
Copy link
Contributor

tgodzik commented Jun 16, 2024

Ach, actually I think for Scala 3 we use the normal to String and that's the actual toString method. Better to use List in worksheets.

Take a look at https://scastie.scala-lang.org/msia7oRwQdav11jDrGGVag

@tgodzik tgodzik added needs more information Use if we need more information for a specific ticket and removed bug Something that is making a piece of functionality unusable upstream-fix-needed Waiting on a fix upstream labels Jun 16, 2024
@Leon0402
Copy link
Author

Makes sense, seems like List is preferred over Array in most cases. In the book I use (scala for the impatient) arrays are introduced first and lists mentioned much later, I wonder why.

Nevertheless, it would probably be still good to fix this case, right? There are probably other cases, where the logic currently fails if it relies on the toString method (Possibly everywhere, where we deal with more classic Java types?).

@tgodzik
Copy link
Contributor

tgodzik commented Jun 17, 2024

Nevertheless, it would probably be still good to fix this case, right? There are probably other cases, where the logic currently fails if it relies on the toString method (Possibly everywhere, where we deal with more classic Java types?).

I think from the usability standpoint yes, but correctness wise it might not be a perfect solution. If one expects things on the right to be just a toString then this will make people think that Arrays are nicely printable, but they're not, they lack a proper toString. Most Java types have a sensible toString, so this is really mostly an issue with Arrays which is the wrapper around the primitive arrays.

The other solution is to use pprint library as for Scala 2, but I was faced with opposition to it as it is more principled for some people to always just use toString. So, overall I am not sure what is best here :/

@tgodzik tgodzik removed the needs more information Use if we need more information for a specific ticket label Jun 19, 2024
@kasiaMarek kasiaMarek added this to the Metals v1.3.4 milestone Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
worksheets Use for tickets related to worksheets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants