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

[Feature] Implement try/catch statement to handle exceptions #654

Open
2 of 4 tasks
Tracked by #694
lorenzholzbauer opened this issue Jul 9, 2024 · 0 comments
Open
2 of 4 tasks
Tracked by #694
Assignees
Labels
feature New feature or enhancement
Milestone

Comments

@lorenzholzbauer
Copy link
Member

lorenzholzbauer commented Jul 9, 2024

Is there an existing proposal for this?

  • I have searched the existing issues

This feature does not exist in the latest version

  • I am using the latest version

Proposal

Add try/catch statement support, which can handle exceptions and execute specific clauses based on error pattern matching. It also includes a finally clause, which gets executed regardless of what happened before.

var x: num;
try {
  x = fetch("http://localhost") force as num;
} catch (e: InvalidCastException) {
  x = 2;
} finally {
  print(x as str):
}

Exact behaviour / changes you want

  • Add try/catch notation and appropriate semantic analysis.
  • Add translation to JavaScript and TypeScript.
@lorenzholzbauer lorenzholzbauer added feature New feature or enhancement question Further information is requested labels Jul 9, 2024
@lorenzholzbauer lorenzholzbauer self-assigned this Jul 9, 2024
@Luna-Klatzer Luna-Klatzer changed the title [Feature] Implement Try/Catch Statement to handle Exceptions [Feature] Implement try/catch statement to handle exceptions Jul 9, 2024
@Luna-Klatzer Luna-Klatzer changed the title [Feature] Implement try/catch statement to handle exceptions [Feature] Implement try/except statement to handle exceptions Jul 25, 2024
@Luna-Klatzer Luna-Klatzer removed the question Further information is requested label Jul 25, 2024
@Luna-Klatzer Luna-Klatzer added this to the v0.12.0 milestone Jul 25, 2024
@lorenzholzbauer lorenzholzbauer changed the title [Feature] Implement try/except statement to handle exceptions [Feature] Implement try/catch statement to handle exceptions Aug 17, 2024
@Luna-Klatzer Luna-Klatzer modified the milestones: v0.12.0, v0.13.0 Sep 16, 2024
lorenzholzbauer added a commit that referenced this issue Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or enhancement
Projects
Status: In Progress
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants