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.
FWIW this issue is blocking flutter migration to nullsafety.
Where's the cringey-face emoji... What a weird bug. I'll look at this today.
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:
analyzer:
enable-experiment:
- non-nullable
null-safety
experiment? If you are invoking it through pub, its probably something like pub global run dartdoc --enable-experiment=null-safety
.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
@srawlins have you been able to reproduce the issue?
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?
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.
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 :-(
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.
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.
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.
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.
FWIW, I don't see --enable-experiment=non-nullable
in the dartdoc invocation on the linked linux bot.
I don't see --enable-experiment=non-nullable
in your cirrus link, nor in the latest cirrus link on your PR.
Good catch! It should fix the issue.
(But locally I really don't know what I did to see this issue)
Let us know if that works. I plan on publishing dartdoc tomorrow morning, after it is vetted internally.
Adding --enable-experiment=non-nullable
fixed the issue. Thanks for your help.