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

[vm/ffi] No error if Pointer type is a top type #47746

Open
sgrekhov opened this issue Nov 22, 2021 · 0 comments
Open

[vm/ffi] No error if Pointer type is a top type #47746

sgrekhov opened this issue Nov 22, 2021 · 0 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. library-ffi

Comments

@sgrekhov
Copy link
Contributor

The following code works without any issues

import "dart:ffi";
import 'package:ffi/ffi.dart';

void main() {
  Pointer<Int16> p = calloc<Int16>();

  Pointer<dynamic> p1 = Pointer.fromAddress(p.address);
  Pointer<void> p2 = Pointer.fromAddress(p.address);
  Pointer<Object?> p4 = Pointer.fromAddress(p.address);
  Pointer<Never> p5 = Pointer.fromAddress(p.address);
}

For the comparison, Array class produces errors for all of the types mentioned above

class MyStruct extends Struct {
  @Array(16)
  external Array<void> a2;
//               ^^^^
// [analyzer] unspecified
// [cfe] unspecified

  @Array(16)
  external Array<dynamic> a3;
//               ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

  @Array(16)
  external Array<Object?> a5;
//               ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

  @Array(16)
  external Array<Never> a6;
//               ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

I believe, Pointer class should produce error for these types as well

Tested on Dart SDK version: 2.16.0-edge.3d1f6a48b79e2cc5a4ee9d2ea3a7a385a3b33eaa (be) (Thu Nov 18 00:58:40 2021 +0000) on "windows_x64"

cc @dcharkes

@sgrekhov sgrekhov added area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. library-ffi labels Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. library-ffi
Projects
None yet
Development

No branches or pull requests

1 participant