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

Issue with the array type #1728

Open
sorawee opened this issue Mar 13, 2024 · 5 comments
Open

Issue with the array type #1728

sorawee opened this issue Mar 13, 2024 · 5 comments

Comments

@sorawee
Copy link
Contributor

sorawee commented Mar 13, 2024

import arrays as arr

fun test(xs :: Array<Number>):
  xs.get-now(1)
end

fails with

The type checker rejected your program because it found a Any but it expected a a polymorphic type

when it's run with the type checker on.

However, this program works fine.


import arrays as arr

fun test(xs :: arr.Array<Number>):
  xs.get-now(1)
end

It looks like something's gone wrong with the default namespace?

Originally reported by B Nagy András in Discord.

@blerner
Copy link
Member

blerner commented Apr 30, 2024

@jpolitz this one's weird -- I think this has to do with the fact that Array is declared as a newtype in arrays.arr, and not really as a data, and the newtype declaration doesn't have any way to indicate that it has type arguments? So I'm actually more surprised that the second example does type-check, since I see no reason from the arrays code that it should.

@jpolitz
Copy link
Member

jpolitz commented May 1, 2024

Ugh, Array. This issue makes me feel that the right solution is probably to deprecate it (and newtype) and change Array to a real datatype. That or deprecate the Array datatype entirely; I think basically all use cases are better served by raw-array. I think it's basically the only source use of newtype in the whole runtime library, and no one really uses it other than that. I suppose Array could allow for [] since it can have methods, but I'm not sure that's a great argument for keeping it.

@sorawee do you mind sharing what you were writing when you found this?

@sorawee
Copy link
Contributor Author

sorawee commented May 1, 2024

Here's the repaired program written by B Nagy András.

https://code.pyret.org/editor#share=1bVMDO1TN8XX_jlnOIBMeONfMtr-WBg0d&v=0c33ff0

If I'm not mistaken, he is managing https://exercism.org/tracks/pyret, and this is one of the ported problems that he tried out to make sure it's feasible to solve.

EDITED: A couple of other solutions here: https://exercism.org/tracks/pyret/exercises/circular-buffer/solutions

There gotta be a stencil file somewhere, but I couldn't find it.

@sorawee
Copy link
Contributor Author

sorawee commented May 1, 2024

Ah, his GitHub handler is @BNAndras.

@BNAndras
Copy link

BNAndras commented May 1, 2024

Yup, that’s correct.

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

4 participants