The value get can't be found in Array?

I havnt found a repro using the playground but keep getting this error about

The value get can't be found in Array

Hint: Did you mean set?

When I have a very clear cut array dereference.
I have been working around using Belt.Array.getExn or whatever but seems like a pretty fundamental thing to be cheating.

Has anyone else seen this? Is this a known thing?

Do you have a custom Array module that’s shadowing the built-in one?

I do have a custom Array.res but surprised that conflicts with builtin array
I have namespace=true in my bsconfig.
Sounds like Im very close to where the abstraction ends

1 Like

This is why I told about scope/namespace for files

The array access (a[i]) syntax just desugars to Array.get(a, i). It’s only a syntax transform, which means that the compiler will then use whichever Array module is in scope, exactly as if you had written Array.get(a, i) manually.

One easy workaround is to put this in your Array.res module:

// Array.res
let get = Belt.Array.get

namespace=true wraps the package in a namespace for other projects, not within the same project.


Would be nice if it desugared to Belt.Array.get and avoided this.

1 Like