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

2 late field of the same type leads to error #2273

Closed
a14n opened this issue Jul 24, 2020 · 17 comments
Closed

2 late field of the same type leads to error #2273

a14n opened this issue Jul 24, 2020 · 17 comments
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@a14n
Copy link
Contributor

a14n commented Jul 24, 2020

With 2 late fields of the same type like the following code:

class A {
  late double a;
  late double b;
}

dartdoc --enable-experiment=non-nullable outputs error:

Generating docs for library a from package:hello_world/a.dart...
  error: failed to write file at: a/A/double.html, for symbol a.A.double: (file:///home/a14n/hello_world/lib/a.dart:2:8)
            Dartdoc generates a path and filename to write to for each symbol.
            a.A.double conflicts with another symbol in the generated path, and
            therefore can not be written out.  Changing the name, library name, or
            class name (if appropriate) of one of the conflicting items can resolve
            the conflict.   Alternatively, use the @nodoc tag in one symbol's
            documentation comments to hide it.

With only one late field no issue appears.

@srawlins srawlins added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P1 A high priority bug; for example, a single project is unusable or has many test failures labels Jul 24, 2020
@a14n
Copy link
Contributor Author

a14n commented Jul 24, 2020

FWIW this issue is blocking flutter migration to nullsafety.

@srawlins
Copy link
Member

Where's the cringey-face emoji... What a weird bug. I'll look at this today.

@srawlins
Copy link
Member

dartdoc does not see your source as being opted in to the null-safety feature. There are like, 17 reasons this might be, haha. Can you check the following:

  1. Is the package opted into null-safety via SDK constraints? I think this might involve 2.9 or 2.10 depending on the version of Dart you are using.
  2. Is the package opted into null-safety via analysis_options?
analyzer:
  enable-experiment:
    - non-nullable
  1. Are you running dartdoc with the null-safety experiment? If you are invoking it through pub, its probably something like pub global run dartdoc --enable-experiment=null-safety.

@a14n
Copy link
Contributor Author

a14n commented Jul 24, 2020

yes I have a simple package with

//------ analysis_options.yaml
analyzer:
  enable-experiment:
  - non-nullable
//------ pubspec.yaml
name: hello_world
environment:
  sdk: ">=2.9.0-14.0.dev <3.0.0"
//------ lib/a.dart
class A {
  late double a;
  late double b;
}

And I run dartdoc --enable-experiment=non-nullable (same error with dartdoc --enable-experiment=null-safety).

You can see the failure on my flutter PR https://cirrus-ci.com/task/4975447580606464?command=main#L137

@a14n
Copy link
Contributor Author

a14n commented Jul 28, 2020

@srawlins have you been able to reproduce the issue?

@devoncarew
Copy link
Member

FWIW this issue is blocking flutter migration to nullsafety

Is this blocking the migration? Blocking some aspect of it? Do you have a workaround in the near-term?

@srawlins
Copy link
Member

I have not been able to reproduce this when opting in to null safety via pubspec:

environment:
  sdk: '>=2.9.0-18.0 <2.9.0'

and analysis_options:

analyzer:
  enable-experiment:
    - non-nullable

and using dartdoc at head, running dart at head:

~/code/dart-sdk/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dart
    --enable-experiment=non-nullable
    ../dart-dartdoc/bin/dartdoc.dart
    --enable-experiment=non-nullable

I am in the process of releasing dartdoc, since its been a while. I'll also check on the current most recent release.

@a14n
Copy link
Contributor Author

a14n commented Jul 28, 2020

Is this blocking the migration? Blocking some aspect of it?

Yes because docs-linux job is always failling. (See flutter/flutter#62157)

Do you have a workaround in the near-term?

Remove all late is not really a workaround because it will need to add ! and ? everywhere :-(

@a14n
Copy link
Contributor Author

a14n commented Jul 28, 2020

The failing job mention dartdoc version: 0.32.1 . Could you check that this version triggers the issue on your side? If you see the issue it could mean that it has been fixed at some point and the next release will solve the issue.

@devoncarew
Copy link
Member

Gotcha; I was hoping for some flags we could pass to dartdoc (or flags we could omit) which would let us proceed in the meantime.

@srawlins - I think a fix here will be important to let the nnbd migration progress generally.

@srawlins
Copy link
Member

Yes it looks like I can reproduce this on 0.32.1, using Dart 2.10.0-dev.something. There is an unreleased 0.32.2 which might work. I'll try that as well.

@srawlins
Copy link
Member

srawlins commented Jul 28, 2020

I can reproduce using pub global run on the v0.32.2 git tag, and on master. So I cannot reproduce when using dart --enable-experiment=non-nullable ../dart-dartdoc/bin/dartdoc.dart --enable-experiment=non-nullable but I can when using pub [global] run dartdoc --enable-experiment=non-nullable. I'm working on looking at why pub is the culprit.

Scratch that. I had a stray // @dart=2.9 in my test file (which is now too low to indicate Null safety).

I cannot reproduce the error with pub run dartdoc on dartdoc 0.32.1, nor git branch v0.32.2, nor at head.

@devoncarew
Copy link
Member

FWIW, I don't see --enable-experiment=non-nullable in the dartdoc invocation on the linked linux bot.

@srawlins
Copy link
Member

I don't see --enable-experiment=non-nullable in your cirrus link, nor in the latest cirrus link on your PR.

@a14n
Copy link
Contributor Author

a14n commented Jul 28, 2020

Good catch! It should fix the issue.

(But locally I really don't know what I did to see this issue)

@srawlins
Copy link
Member

Let us know if that works. I plan on publishing dartdoc tomorrow morning, after it is vetted internally.

@a14n
Copy link
Contributor Author

a14n commented Jul 28, 2020

Adding --enable-experiment=non-nullable fixed the issue. Thanks for your help.

@a14n a14n closed this as completed Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants