Skip to content

CFE and duplicate unnamed variables #59664

@jensjoha

Description

@jensjoha

This code crashes when issuing errors because there's no name:

$ cat pkg/front_end/testcases/regress/duplicate_unnamed.dart
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

void foo(dynamic bar) {
  final [ void, void ] = bar;
}

Allowing there to be no name it crashes upon loading the serialized dill because on serializing the empty name becomes null and the name is only allowed to be null if it's synthetic.
If making it synthetic the serialized-and-loaded-back-again version is different from the version that isn't:

-  final synthesized hoisted has-declared-initializer void;
-  final synthesized hoisted void = invalid-expression "pkg/front_end/testcases/regress/duplicate_unnamed.dart:6:22: Error: '(unnamed)' is already declared in this scope.
+  final hoisted has-declared-initializer void #t1;
+  final hoisted void #t2 = invalid-expression "pkg/front_end/testcases/regress/duplicate_unnamed.dart:6:22: Error: '(unnamed)' is already declared in this scope.

While I think this situation should just be accepted I can't come up with an easy/good (or any, currently) way of making this not crash or be bad in some way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions