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

Test element type of generator functions #2139

Closed
eernstg opened this issue Jul 17, 2023 · 0 comments
Closed

Test element type of generator functions #2139

eernstg opened this issue Jul 17, 2023 · 0 comments
Assignees
Labels
type-enhancement A request for a change that isn't a bug

Comments

@eernstg
Copy link
Member

eernstg commented Jul 17, 2023

We've noticed a soundness issue with the element type of generator functions, as mentioned in
dart-lang/language#3218.

@sgrekhov, it would be great if you could star that pull request, and write some language tests when it has been resolved!

In particular, we should cover the currently unsound behavior associated with examples given here, and we should cover the run-time types of objects returned by generator functions. We'd expect is Iterable<T> for a suitable T, or is Stream<T>. It's a bit less convenient to verify that the iterable/stream has an actual type argument which isn't too special (if we expect an Iterable<num> we shouldn't get an Iterable<int>), but it should be possible to build on this idea:

X combine<X>(X x, X _) => x;

void main() {
  List<num> xs = <int>[1];
  print('Combine for int:');
  (xs.reduce as dynamic)(combine<int>); // Type correct at run time. Ignore the type checker.
  print('Still alive. Combine for num:');
  xs.reduce(combine<num>);
  print('Not reached');
}
@sgrekhov sgrekhov self-assigned this Jul 18, 2023
@sgrekhov sgrekhov added the type-enhancement A request for a change that isn't a bug label Jul 18, 2023
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Jul 19, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Aug 16, 2023
2023-08-16 [email protected] Fixes dart-lang/co19#2211. Fix roll failures (dart-lang/co19#2212)
2023-08-16 [email protected] dart-lang/co19#2142. Add more dynamic semantics and member invocation tests (dart-lang/co19#2210)
2023-08-15 [email protected] dart-lang/co19#2142. Delete obsolete Inline-classes tests (dart-lang/co19#2209)
2023-08-14 [email protected] dart-lang/co19#2207. Fix roll failures (dart-lang/co19#2208)
2023-08-14 [email protected] Fixes dart-lang/co19#2195. Fix typos and a runtime error in static_analysis_member_invocation_A07_t01.dart (dart-lang/co19#2204)
2023-08-14 [email protected] Fixes dart-lang/co19#2196. Expect additional error in syntax_A04_t01.dart (dart-lang/co19#2205)
2023-08-14 [email protected] dart-lang/co19#2142. Move and rename dynamic semantics extension type tests (dart-lang/co19#2206)
2023-08-14 [email protected] Fixes dart-lang/co19#2190. Fix representation dependency in static_analysis_extension_types_A19_t01.dart (dart-lang/co19#2198)
2023-08-14 [email protected] Fixes dart-lang/co19#2194. Fix typo in static_analysis_extension_types_A21_t06.dart (dart-lang/co19#2203)
2023-08-14 [email protected] Fixes dart-lang/co19#2191. Fix typos in static_analysis_extension_types_A21_t01.dart (dart-lang/co19#2199)
2023-08-14 [email protected] Fixes dart-lang/co19#2189. Fix typos in extension types tests (dart-lang/co19#2200)
2023-08-14 [email protected] Fixes dart-lang/co19#21892. Fix typo in static_analysis_extension_types_A21_t02.dart (dart-lang/co19#2201)
2023-08-14 [email protected] Fixes dart-lang/co19#21892. Fix typo in static_analysis_extension_types_A21_t05.dart (dart-lang/co19#2202)
2023-08-11 [email protected] Fixes dart-lang/co19#2172. Fix error expectations in static_analysis_extension_types_A02_t02.dart (dart-lang/co19#2180)
2023-08-11 [email protected] dart-lang/co19#2142. Change dynamic semantics inline class tests to be extension type tests (dart-lang/co19#2188)
2023-08-11 [email protected] dart-lang/co19#2142. Move static analysis member invocation tests to Extension types dir (dart-lang/co19#2187)
2023-08-11 [email protected] Fixes dart-lang/co19#2174. Add missing import (dart-lang/co19#2182)
2023-08-11 [email protected] dart-lang/co19#2142. Rename and move tests to Extension type dir (dart-lang/co19#2186)
2023-08-11 [email protected] Fixes dart-lang/co19#2175. Fix tests that check extension types implementing enumerated types (dart-lang/co19#2183)
2023-08-11 [email protected] Fixes dart-lang/co19#2176. Fix unintended error in static_analysis_extension_types_A11_t01.dart (dart-lang/co19#2184)
2023-08-11 [email protected] Fixes dart-lang/co19#2177. Fix typo in static_analysis_extension_types_A16_t05.dart (dart-lang/co19#2185)
2023-08-11 [email protected] Fixes dart-lang/co19#2173. Fix tests checking use of await for extension types (dart-lang/co19#2181)
2023-08-11 [email protected] Fixes dart-lang/co19#2171. Fix typos, adjust error expectations (dart-lang/co19#2179)
2023-08-10 [email protected] dart-lang/co19#2142. Change composing inline class tests to be extension type tests (dart-lang/co19#2170)
2023-08-10 [email protected] Fixes dart-lang/co19#2167. Fix typo in static_analysis_extension_types_A17_t01.dart (dart-lang/co19#2168)
2023-08-10 [email protected] Fixes dart-lang/co19#2139. Add generator functions element type tests (dart-lang/co19#2153)
2023-08-09 [email protected] dart-lang/co19#2142. Change static analysis member invocation tests to be extension type tests (dart-lang/co19#2150)
2023-08-08 [email protected] dart-lang/co19#2142. Add more static analysis of extension types tests (dart-lang/co19#2166)
2023-08-08 [email protected] dart-lang/co19#2142. Add more static analysis tests (dart-lang/co19#2165)

Change-Id: Ib1f0a9a1f2615b9f9783b1d7fa1b60c4d6c0389c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321140
Commit-Queue: Erik Ernst <[email protected]>
Reviewed-by: Erik Ernst <[email protected]>
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Dec 14, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Dec 19, 2023
2023-12-19 [email protected] Fixes dart-lang/co19#2441. Fix roll failures (dart-lang/co19#2443)
2023-12-18 [email protected] Fixes dart-lang/co19#2435. Fix roll failures (dart-lang/co19#2437)
2023-12-18 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Variables (dart-lang/co19#2431)
2023-12-15 [email protected] Fixes dart-lang/co19#2430. Update expected errors positions for CFE (dart-lang/co19#2433)
2023-12-15 [email protected] Fixes dart-lang/co19#2432. Remove excessive expected error for CFE (dart-lang/co19#2434)
2023-12-14 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Maps (dart-lang/co19#2426)
2023-12-14 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Lists (dart-lang/co19#2424)
2023-12-14 [email protected] dart-lang/co19#2139. Fix wrong failure of Language/Functions/element_type_A02_t06 (dart-lang/co19#2429)
2023-12-13 [email protected] dart-lang/co19#2350. Add more factory constructors tests (dart-lang/co19#2427)
2023-12-13 [email protected] Fixes dart-lang/co19#2415. Update `StreamController.broadcast()` test according to the changed documentation (dart-lang/co19#2425)
2023-12-13 [email protected] dart-lang/co19#2350. Add/update factory constructor tests. Part 4 (dart-lang/co19#2367)
2023-12-12 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Enums, trivial cases (dart-lang/co19#2423)
2023-12-11 [email protected] dart-lang/co19#2420. Add extension types exhaustiveness tests. Enums (dart-lang/co19#2422)
2023-12-11 [email protected] dart-lang/co19#2386. Rename well-bounded tests. Update descriptions (dart-lang/co19#2405)
2023-12-08 [email protected] dart-lang/co19#2415. Change expectations for Stream.asyncMap() according to the current behavior (dart-lang/co19#2421)

Change-Id: I777eba4f1615c8477a5d2044f295696dfc210b1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342582
Commit-Queue: Erik Ernst <[email protected]>
Reviewed-by: Alexander Thomas <[email protected]>
Reviewed-by: Erik Ernst <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants