Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error quality of life: trailing ? missing on a ?? assignment does not give a nice error #2036

Closed
joshring opened this issue Mar 10, 2025 · 1 comment
Assignees
Labels
Accepted Accepted Request Enhancement Request New feature or request
Milestone

Comments

@joshring
Copy link
Contributor

module faults;
fault
    EXAMPLE,
    DOG_ATE_MY_HOMEWORK,
    MY_TEXTBOOK_CAUGHT_FIRE,
    DISTRACTED_BY_CAT_PICTURES;


module testing_v0_7;
import faults;
import std::io;

fn int main(String[] args)
{

	int? foo = faults::EXAMPLE?; // miss the trailing `?` here and get a nice error: `Error: You need to add a trailing '?' here to make this an optional.`


	if (catch foo)
	{
		foo = foo ?? faults::DISTRACTED_BY_CAT_PICTURES; // Not such a clear error: `Error: Cannot find a common type for 'int' and 'anyfault'.`
		io::printfn("foo = %s", foo)!!;
	}

	return 0;
}
@lerno lerno added Enhancement Request New feature or request Accepted Accepted Request labels Mar 10, 2025
@lerno lerno added this to the 0.7.0 milestone Mar 10, 2025
@lerno lerno self-assigned this Mar 10, 2025
@lerno lerno added Accepted Accepted Request and removed Accepted Accepted Request labels Mar 10, 2025
lerno added a commit that referenced this issue Mar 10, 2025
@joshring
Copy link
Contributor Author

Nice 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted Request Enhancement Request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants