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 program containing Float32List #2903

Closed
Fox32 opened this issue Mar 17, 2024 · 2 comments
Closed

Issue with program containing Float32List #2903

Fox32 opened this issue Mar 17, 2024 · 2 comments

Comments

@Fox32
Copy link

Fox32 commented Mar 17, 2024

What happened?

I created the following program in Dart Pad:

import 'dart:typed_data' ;
import 'dart:math';

extension type Vector3(Float32List storage) {
  
  Vector3.zero() : storage = new Float32List.fromList([0.0, 0.0, 0.0]);
    
  double get length => sqrt(storage[0] * storage[0] + storage[1] * storage[1] + storage[2] * storage[2]);
  
}

void main() {
  final v0 = new Vector3.zero();
    
   print(v0.length);
}

It runs with the Dart VM on Dart SDK version: 3.3.1 (stable) (Wed Mar 6 13:09:19 2024 +0000) on "macos_arm64" . However it fails with an error in Dart Pad:

Uncaught TypeError: typed_data.Float32List.fromList is not a function, error: TypeError: typed_data.Float32List.fromList is not a function

Steps to reproduce problem

  1. Paste the code above
  2. Press run

Additional info

Browser

Browser: Chrome

Version: Based on Dart SDK 3.0.0 and Flutter SDK 3.19.2

Are you using any extensions/plugins that affect website behavior
(particularly those that affect iframes, such as ad blockers)?

Are there any warnings or errors in your browser's JavaScript console?
If so, paste them below:

VM302:64 Uncaught TypeError: typed_data.Float32List.fromList is not a function
    at Object.Vector3$124constructor$35zero [as Vector3|constructor#zero] (<anonymous>:64:40)
    at Object.main$0 [as main] (<anonymous>:74:46)
    at Object.main$ [as main] (<anonymous>:54:10)
    at <anonymous>:113:26
    at Object.execCb (require.js:5:16727)
    at e.check (require.js:5:10499)
    at e.<anonymous> (require.js:5:12915)
    at require.js:5:1542
    at require.js:5:13376
    at each (require.js:5:1020)
    at e.emit (require.js:5:13344)
    at e.check (require.js:5:11058)
    at e.enable (require.js:5:13242)
    at e.init (require.js:5:9605)
    at a (require.js:5:8305)
    at Object.completeLoad (require.js:5:15962)
    at HTMLScriptElement.onScriptLoad (require.js:5:16882)

Machine

Operating system: MacOS

Version: 13.4

Your code

What code was in the editor, if any, when the failure occurred? You
can paste it in below:

import 'dart:typed_data' ;
import 'dart:math';

extension type Vector3(Float32List storage) {
  
  Vector3.zero() : storage = new Float32List.fromList([0.0, 0.0, 0.0]);
    
  double get length => sqrt(storage[0] * storage[0] + storage[1] * storage[1] + storage[2] * storage[2]);
  
}

void main() {
  final v0 = new Vector3.zero();
    
   print(v0.length);
}

DartPad's output

Did DartPad print anything to the console pane? If so, paste it below:

Uncaught TypeError: typed_data.Float32List.fromList is not a function, error: TypeError: typed_data.Float32List.fromList is not a function

If you were running Flutter code, you can also paste an image of the
Flutter output directly into this bug report.

@cmkweber
Copy link

dart-lang/sdk#55135

This was a dart issue related to forwarding constructors, it was cherry picked but hasn’t made it to dart pad yet.

@Fox32
Copy link
Author

Fox32 commented Mar 21, 2024

Thanks for letting me know, than it will probably land soon 🙂

@Fox32 Fox32 closed this as completed Mar 21, 2024
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

2 participants