flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

[Dart, master] Recursive imports are not respected

Open insertjokehere opened this issue 1 year ago • 0 comments

Consider the following schemas:

  • includes_a.fbs:
namespace a;

table a {
  options: uint8;
}
  • includes_b.fbs:
include 'includes_a.fbs';

namespace a;

table b {
  my_a: a;
}
  • includes_c.fbs:
include 'includes_b.fbs';

namespace a;

table c {
  my_a: a;
  my_b: b;
}

The docs (https://flatbuffers.dev/md__schemas.html) are vague on if this is valid, but as far as I can tell this is supposed to work - c imports b, which imports a, so a and b are in scope in c.

When generating Dart bindings (flatc --dart --gen-object-api *.fbs), this relationship is reflected in the Dart code - includes_c_a_generated.dart imports includes_b_a_generated.dart, which imports includes_a_a_generated.dart - however, this is not how imports in Dart work. Importing b.dart in c.dart does not bring the contents of a.dart into scope unless b.dart explicitly exports the file.

I've not taken a survey of other generators, but I suspect this affects other languages as well.

insertjokehere avatar Aug 20 '24 01:08 insertjokehere