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

Int16List performs implicit conversions when assigning list elements #70

Open
jamescrosswell opened this issue Jul 22, 2023 · 0 comments

Comments

@jamescrosswell
Copy link

Some of the Dart code I'm working with reads unsigned 16 bit data from a Wav file into an IntList... and I noticed something odd going on.

The following test fails with Expected: <65508> Actual: <-28>:

    test('store_int_in_int16list', () {
      int myInt = 65508;
      Int16List int16 = Int16List(1);
      int16[0] = myInt;
      expect(int16[0], 65508);
    });

I noted Dart doesn't let you assign int to Int16. The following code gives a compiler error and politely asks that the int be cast to Int16:

      int myInt = 65508;
      Int16 int16 = myInt;

So I suspect the assignment of an int to an element in an Int16List shouldn't be allowed either. I'm not sure if it's easy/possible to catch that though.

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

1 participant