swift: Error messages for failure to infer generic parameter and opaque result type should be aligned
Description
Consider these two errors:
func f1<T>() -> T { fatalError() }
f1() // error: generic parameter 'T' could not be inferred
func f2() -> Optional<some Sequence> {
return nil // error: cannot infer underlying type for opaque result 'Optional<some P>' from return expression
}
Interestingly, the second error is a tailored version of the first, because the underlying type of an opaque result type is in fact a generic parameter of the implicit opaque result type declaration. So these errors are fundamentally one and the same, but the difference in their phrasings is hardly enlightening in this respect. A wording for the second error that is more similar to that of the much more familiar first error would facilitate our efforts in presenting this feature as an extension of the generics system. For example, underlying type for opaque result type '...' could not be inferred from return expression
.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 97 (54 by maintainers)
Commits related to this issue
- Fixed Issue #63291 by aligning error messages for failure to infer generic parameter and opaque result type. — committed to Rajveer100/swift by deleted user a year ago
- Fix Issue #63291 by aligning error messages for failure to infer generic parameter and opaque result type. — committed to Rajveer100/swift by deleted user a year ago
- [Sema] Fix Issue #63291 by aligning error messages for failure to infer generic parameter and opaque result type — committed to Rajveer100/swift by deleted user a year ago
- [Sema] Fix Issue #63291 by aligning error messages for failure to infer generic parameter and opaque result type — committed to Rajveer100/swift by deleted user a year ago
- [Sema] Align error messages for failure to infer generic parameter and opaque result type Fixes #63291. — committed to Rajveer100/swift by deleted user a year ago
- [Sema] Align error messages for failure to infer generic parameter and opaque result type Fixes #63291. — committed to Rajveer100/swift by deleted user a year ago
- Merge pull request #63567 from Rajveer100/branch-for-issue-63291 [Sema] Fix Issue #63291 by aligning error messages for failure to infer generic parameter and opaque result type — committed to apple/swift by ahoppen a year ago
You may also want to read through our commit message formatting recommendations.
Oh wait, I changed the
ARGUMENTS
in the info tab tobin/swift-frontend
, now it’s working without the Ninja commandOkay, now that we’ve found the message, I trust you can figure out how to modify it and test your changes. Once you’re happy with the new message, don’t forget to update any tests that verify the old message!
Yes!
Yes, the goal is to find where the error message is defined, so you can edit it. You can either try
grep
ing it or use the flag.The other approach is to use a frontend flag.
To track down where the error is being generated, use
git grep
(or something similar) to search the code for the error message. That will show you where the message is defined. You can then search for the error message identifier to see where the error is actually being detected.Keep reading the guide, you might find some valuable resources at the end. Searching for keywords apart from reading, be it in a browser of file system, is often very helpful too.
I mean without the
$(ACTION)
.I see, thanks. The part about the architecture is no longer relevant.
If you want to build in Xcode as opposed to the command line, you will have to manually create and configure Xcode targets and hook them up to
ninja
commands.swift-frontend
is the only target you need. The next step explains how to configure the Xcode target.It is indeed a typo. I changed the default build variant for
--xcode
the other day and forgot to update the documentation.Yep, see? That’s a typo right there.
Yes, only once you’re able to reproduce an issue with a locally built compiler does it make sense to start addressing it. Note that setting up an Xcode workspace is just one option — the IDE/editor choice, as well as whether you use the editor or a terminal to build/run/debug is entirely up to you.