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

Dart 2.0 support #23

Open
elmcrest opened this issue Aug 8, 2018 · 8 comments · May be fixed by #24
Open

Dart 2.0 support #23

elmcrest opened this issue Aug 8, 2018 · 8 comments · May be fixed by #24

Comments

@elmcrest
Copy link

elmcrest commented Aug 8, 2018

Hey,

since strong_mode is working I was thinking Dart 2 is already supported, but if I try to pub get ^1.0.0 of parsers I'll get:

Resolving dependencies...
The current Dart SDK version is 2.0.0.

Because systori depends on parsers >=0.0.2 which requires SDK version <2.0.0, version solving failed.
@elmcrest
Copy link
Author

elmcrest commented Aug 9, 2018

ok, I've forked parsers and installed it locally just to remove the dart 2.0 constraint. sadly it doesn't work.

f.e. running full_arith.dart leads to:

[Running] dart "/home/elmcrest/projects/parsers/example/full_arith.dart"
Unhandled exception:
type '() => dynamic' is not a subtype of type '() => Parser<dynamic>'
#0      Arith.expr (file:///home/elmcrest/projects/parsers/example/full_arith.dart:30:17)
#1      Arith.start (file:///home/elmcrest/projects/parsers/example/full_arith.dart:21:16)
#2      main (file:///home/elmcrest/projects/parsers/example/full_arith.dart:44:17)
#3      _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19)
#4      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)

let me know if I could somehow help you with making parsers work on dart 2.0

@polux
Copy link
Owner

polux commented Aug 9, 2018

Hi, what happened is: a while ago I wanted to make parsers dart 2 ready so I fixed all strong mode errors but didn't bump the dart version constraint as 2 hadn't launched. In the meantime, the dart 2 runtime added more runtime checks and those are now catching more type errors than the analyzer. Looks like the analyzer is not complete, or wasn't at the time (source: polux/propcheck#2 (comment)).

I need to run the tests and fix the type annotation or add casts where the type system cannot express the invariants of the lib. I have no idea how much work this represents: I'll discover it as I go.

Unfortunately I don't have much time for this righ now. If you're willing to give it a try, I'll happily review your PRs. If not I'll have a look when I get some time.

@elmcrest
Copy link
Author

elmcrest commented Aug 9, 2018

as of now this is way above my head :)

but, I'm migrating some other less advanced dart stuff to dart 2.0 and see how much I'll get along the way... maybe I could give it a try then an create a PR.

Though, tbh, another option might be that I'll trash Dart alltogether... just saying in case this issue gets old over time and nothing happens :P

@polux
Copy link
Owner

polux commented Aug 9, 2018

Sure, do what works best for you. You can also have a look at PetitParser, another dart parser combinator library.

@devkabiir
Copy link

devkabiir commented Apr 23, 2019

Hi @polux, Working with @elmcrest I'm trying to bring in the Dart 2.0 support. devkabiir/parsers. So far I've fixed most type casting issues. The main thing I see is Dart doesn't support type parameters for operators and since they are heavily used everywhere all the instances of Parser loose their type to dynamic which the compiler complains about during type casting. Any ideas @polux on how to move forward with this?

Currently I'm replacing all the operators with their function equivalents to help retain the type info. But that doesn't feel like an efficient way also using operators improves readability of a parser and helps In defining it too. However replacing hasn't proved an easy task so far. 😅

Edit: Updated the link to my repo 😅

@polux
Copy link
Owner

polux commented Apr 24, 2019

Hi Dinesh, this is great! Unfortunately I don't know how to work around the lack of generic arguments for operators issue other than by declaring non-operator methods. I've asked for generic arguments on operators but was told "no" on the grounds that there would be no good syntax for it. So I guess if we want this library to work with dart 2 we have no choice.

@elmcrest
Copy link
Author

from @devkabiir 👍
00:04 +283: All tests passed!

@polux
Copy link
Owner

polux commented Apr 24, 2019

Happy to accept a pull request when this is ready.

@devkabiir devkabiir linked a pull request Apr 24, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants