Closed JordyScript closed 10 months ago
Could you please provide a minimal reproducible sample? Thanks
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hey, sorry for the terribly late response. I had missed the email notification of your response and only now that the stale bot notification came did I see your message.
I've added a sample repository that lets you import the class Data
from the file something.dart
which works normally, but if you try importing the class Data
(which uses a part directive because of json_serializable
) from test_repo.dart
, then the interpreter complains: Hot reload failed, maybe because code has syntax error?
The relevant files are of course located in the lib
folder, and to use the sample repo, you first need to run dart pub install
Hopefully everything is clear like this, but if not feel free to ask questions. I'll check this issue a few times in the next few days to ensure I don't miss your response this time.
Firstly, for your specific case, I guess something.dart and test_repo.dart both have class Data
and that conflicts?
I agree we should have a better error message when hot reload failed (feel free to PR)!
As already mentioned in #88, it seems to be the case that importing packages that depend on the analyzer
package will result in import errors. Files using part directives can be imported without problems.
I did check whether it is possible to import two files that define the same symbol (irrespective of whether the definition is identical or different). Importing does not seem to be a problem, but once you attempt to reference the non-unique symbol that results in an Error.
This is to be expected given that Dart as a language doesn't allow for using an ambiguous symbol as a result of identical symbols being imported from different files / packages. As long as you don't use the non-unique symbol, the code will run even if you import 2 files that contain the same symbol, but once you attempt to use the duplicate symbol that will result in an error. I guess this does not need to be documented, because it is the expected behavior that people should already know from using Dart.
If i link two dart files together using part / part of, then neither can be imported anymore resulting in the warning:
[WARNING 2023-06-13 22:59:22.729208] Error: Hot reload failed, maybe because code has syntax error?
That means code generation such as json_serializable cannot be used