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

prelude.new_array type params differ between declaration and signature computation #1525

Closed
aborgna-q opened this issue Sep 5, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@aborgna-q
Copy link
Collaborator

The type_args are declared as [length, elem_type]

new_array | pop_left | pop_right | get | set | swap => {
vec![TypeArg::BoundedNat { n: self.size }, ty_arg]

But the binary signature computation only uses the element type

let params = vec![TypeBound::Any.into()];
let poly_func_ty = match self {
ArrayOpDef::new_array => PolyFuncTypeRV::new(
params,
FuncValueType::new(vec![elem_ty_var.clone(); n as usize], array_ty),
),
ArrayOpDef::pop_left | ArrayOpDef::pop_right => {

Which one is correct?

@aborgna-q aborgna-q added the bug Something isn't working label Sep 5, 2024
@ss2165
Copy link
Member

ss2165 commented Sep 5, 2024

Not an issue: the computation is two stage - first the length argument is used to compute a function type polymorphic over the element type, which is later initialised by the second type argument

@aborgna-q
Copy link
Collaborator Author

It'd be nice to declare matching args/params on both places to avoid confusion.
Guppy used the ones in the signature definition, and that caused validation to fail.

It looks like using [length, ty] passes validation, so this is not an urgent issue.

@ss2165
Copy link
Member

ss2165 commented Sep 5, 2024

agreed, it is confusing to say the least
Will defer to fallout from #1433 - we may yet get to some simplifications to the polymorphism that help

@doug-q
Copy link
Collaborator

doug-q commented Sep 9, 2024

Closing as NOTABUG, reopen if you disagree

@doug-q doug-q closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants