Closed insanitybit closed 7 years ago
I asked @insanitybit to open this in IRC.
If you look at Directory.open:
fun open(target: String): Directory iso^ ? =>
it takes a single argument that is a string. However, its not a constructor. The error message that results from calling on Directory
the class rather than an instance of the class could be much better.
The simplest thing we could do to improve this UX is to add an "info" line to this (using ast_error_continue
) to point to the definition of the function signature, to show you what arguments are expected, to demonstrate why you're not providing enough. This would be helpful in general, but would also help in this case to show you that it's trying to call the constructor.
@jemc Can you take a look at my fix suggestion.
Error messages for too many / not enough arguments now look like:
Error:
/home/klaunonen/Develop/pony/not_enough-args/argh.pony:5:36: too many arguments
let dirTooManyArgs = Directory(".", 1)
^
Info:
/home/klaunonen/Develop/pony/ponyc-klaunonen/packages/files/directory.pony:32:14: definition is here
new create(from: FilePath) ? =>
^
Error:
/home/klaunonen/Develop/pony/not_enough-args/argh.pony:6:37: not enough arguments
let dirNotEnoughArgs = Directory.open(target)
^
Info:
/home/klaunonen/Develop/pony/ponyc-klaunonen/packages/files/directory.pony:32:14: definition is here
new create(from: FilePath) ? =>
^
@KaroLaunonen - Thanks, looks perfect! Want to file it as a PR?
@jemc If I'm not mistaken, this is resolved as of the May 17 commit https://github.com/ponylang/ponyc/commit/939cf25789c72fec3e623570cb4f8cf934fc6214
@Perelandric - yes, thanks!
not enough arguments let directory = Directory.open(target)