Skip to content

Fasta crash on nested generic function types #31213

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

Closed
sjindel-google opened this issue Oct 24, 2017 · 9 comments
Closed

Fasta crash on nested generic function types #31213

sjindel-google opened this issue Oct 24, 2017 · 9 comments
Assignees
Labels

Comments

@sjindel-google
Copy link
Contributor

sjindel-google commented Oct 24, 2017

$ cat <<EOF >test.dart

typedef C<A, K> = int Function<B>(A x, K y, B v);
typedef D<K> = C<A, K> Function<A>(int z);

dynamic producer<K>() {
  return <A>(int v1) {
    return <B>(A v2, K v3, B v4) => 0;
  };
}

main() {
  assert(producer<String>() is D<String>);
}
EOF

$ DART_CONFIGURATION=DebugX64 ./pkg/front_end/tool/fasta compile test.dart

Unhandled exception:
NoSuchMethodError: The method 'accept' was called on null.
Receiver: null
Tried calling: accept(Instance of '_InnerTypeSubstitutor')
#0      Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)
#1      _TypeSubstitutor.visit (package:kernel/type_algebra.dart:389:41)
#2      _InnerTypeSubstitutor.freshTypeParameter (package:kernel/type_algebra.dart:343:19)
#3      MappedListIterable.elementAt (dart:_internal/iterable.dart:413)
#4      ListIterable.toList (dart:_internal/iterable.dart:218)
#5      _TypeSubstitutor.freshTypeParameters (package:kernel/type_algebra.dart:415:47)
#6      _TypeSubstitutor.visitFunctionType (package:kernel/type_algebra.dart:436:32)
#7      FunctionType.accept (package:kernel/ast.dart:4570:34)
#8      _TypeSubstitutor.visit (package:kernel/type_algebra.dart:389:41)
#9      Substitution.substituteType (package:kernel/type_algebra.dart:239:53)
#10     substitute (package:kernel/type_algebra.dart:19:45)
#11     KernelFunctionTypeAliasBuilder.buildTypesWithBuiltArguments (package:front_end/src/fasta/kernel/kernel_function_type_alias_builder.dart:92:12)
#12     KernelFunctionTypeAliasBuilder.buildType (package:front_end/src/fasta/kernel/kernel_function_type_alias_builder.dart:109:12)
#13     KernelNamedTypeBuilder.build (package:front_end/src/fasta/kernel/kernel_named_type_builder.dart:46:20)
#14     KernelFunctionTypeBuilder.build (package:front_end/src/fasta/kernel/kernel_function_type_builder.dart:40:21)
...
@a-siva
Copy link
Contributor

a-siva commented Oct 24, 2017

cc @sigmundch

@sigmundch sigmundch added the legacy-area-front-end Legacy: Use area-dart-model instead. label Oct 24, 2017
@sjindel-google
Copy link
Contributor Author

@sjindel-google
Copy link
Contributor Author

VM support for nested generic function types in the Kernel FE should be ready.

whesse pushed a commit that referenced this issue Oct 25, 2017
Currently, the Kernel FE doesn't set up parent pointers correctly for
signature function types. This prevents type parameters on generic
function types from being finalized correctly. In addition, finalization
of generic interface types within a generic function type can crash if they
reference not-yet-finalized type parameters of the enclosing function type.

This review solves both issues. Several failing tests pass again, although
more thorough testing is blocked on Github issue #31213 (nested generic function
types crashing in Fasta).

Bug:
Change-Id: Ib5ee6b2566492e3fd6688fe5a6b6976692562ea1
Reviewed-on: https://dart-review.googlesource.com/16360
Reviewed-by: Régis Crelier <[email protected]>
@sjindel-google
Copy link
Contributor Author

When this issue is resolved, support for nested generic function types in the VM's Kernel FE should be tested further.

@peter-ahe-google
Copy link
Contributor

Is running the above program in strong mode sufficient testing?

@sjindel-google
Copy link
Contributor Author

We can't run the program at all through the Kernel FE since Fasta doesn't produce any output.

@peter-ahe-google
Copy link
Contributor

Once this bug in Fasta has been fixed, what would you consider sufficient testing? The above program?

@sjindel-google
Copy link
Contributor Author

It would definitely be a good start, although I would like to write some more involved tests as well.
We are severely lacking test coverage for generic methods and functions.

@peter-ahe-google
Copy link
Contributor

Thank you.

In that case, I suggest you create a separate bug for tracking the test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants