Auto generated package names?

It seems like it is possible to set the package name wrong relative to file structure.

Say I have src folder. Then I create models folder inside and place a file there. In that file I am able to set any package name. It will generate complaints when using it outside the file but there is no complaint when giving the package name

I thought this was a bug at times. I have been programming with flutter in dart a bit as well - so I might have gotten used to auto generated package names.

It seem you can set any package name but that there only is one acceptable package name? But there could also be something I have missed about this.

vscode and many other IDEs autogenerate packages for newly created haxe classes

I had src.models.Person.
When creating new file MyClass - placing it in the same folder I got package models; autogenerated.
So the intelligence was saying both are valid.
Before I had to prepend src.* to my Person file to make it work. Now I could change to models.* for both files
This has happened several times before. I don’t know what triggers its, changing target? I think I have deleted the folder and created new files at some times and pasting in the code
These are just dummy simple classes not importing anything.

It might be some underlaying bug.

typically the src folder is the root, and not a package folder. you can make it a package if you set the root to the parent folder, but that seems like an odd choice

None of the files in src had package declared

None of the files in src had package declared

yeah, you can omit package in toplevel files. that is, you can omit package; when it is empty, like that. this further suggests that src is not a package, therefore packages like src.models.Person should just be models.Person.

So the intelligence was saying both are valid.

both shouldn’t be valid. are you getting any compile errors?

I was trying to reproduce this.

I noticed that package declaration doesn’t update when the files are moved. It could have been what started the issue for me originally.

The Hello file was created in src which generated no package declaration. Then I moved it into models folder. There I had to manually add package models;. It compiled.
Then moving it out into src again it still compiles.

I think I might gotten out of sync from this and also typed wrong package name at some point.


What I am used to in flutter is that package name plays always sticks to the file’s location and they update when being moved across folders