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

Print "'name' is already defined" message #91

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

aqjune
Copy link
Contributor

@aqjune aqjune commented Feb 19, 2024

This is a small patch that updates new_basic_definition and define to print "'name' is already defined" error message if the constant already exists. This also makes new_definition print the message because it internally calls new_basic_definition.

# new_basic_definition `x=10`;;
val it : thm = |- x = 10
# new_basic_definition `x=20`;;
Exception: Failure "new_basic_definition: 'x' is already defined".
# new_definition `x=20`;;
Exception: Failure "new_basic_definition: 'x' is already defined".
# define `x=30`;;
Exception: Failure "define: 'x' is already defined".

Three more definition functions (new_recursive_definition, new_inductive_definition and new_specification) are not updated in this patch. I avoided touching them because their implementations look complicated to me. :/

This updates `new_basic_definition` and `define` to print "'name' is already defined" error message if the constant already exists.
This also makes `new_definition` print the message because it internally calls `new_basic_definition`.

```
\# new_basic_definition `x=10`;;
val it : thm = |- x = 10
\# new_basic_definition `x=20`;;
Exception: Failure "new_basic_definition: 'x' is already defined".
\# new_definition `x=20`;;
Exception: Failure "new_basic_definition: 'x' is already defined".
\# define `x=30`;;
Exception: Failure "define: 'x' is already defined".
```

Three more definition functions (`new_recursive_definition`, `new_inductive_definition` and `new_specification`) are not updated in this patch.
I avoided touching them because their implementations look complicated to me. :/
@jrh13
Copy link
Owner

jrh13 commented Feb 22, 2024

Thanks, a useful improvement in error messages.

@jrh13 jrh13 merged commit 575f952 into jrh13:master Feb 22, 2024
2 checks passed
@aqjune aqjune deleted the define-errmsg branch March 1, 2024 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants