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

Interpreter Needs restarted if the user starts with a Closing Parenthesis ()) #204

Open
TeamSPoon opened this issue Dec 2, 2024 · 1 comment

Comments

@TeamSPoon
Copy link
Collaborator

The metta+> interpreter encounters a critical issue when the user begins an input with a closing parenthesis ()). Instead of producing a syntax error or handling the input gracefully, the interpreter becomes unresponsive and does not process further inputs.


Steps to Reproduce

  1. Start the metta+> interpreter.
  2. Enter a valid input to ensure the interpreter is functioning:
    (+ 1 1)
    • The interpreter processes the input correctly.
  3. Enter an input that begins with a closing parenthesis:
    ) (+ 1 1)
  4. Observe the behavior.

Expected Behavior

  • When encountering an input that starts with a closing parenthesis ()), the interpreter should:
    1. Display a descriptive error message, e.g., "Syntax Error: Input starts with an unmatched closing parenthesis."
    2. Continue to function normally, allowing further inputs.

Actual Behavior

  • The interpreter does not handle this scenario gracefully:
  • No error message is displayed. And the interpeter never works again until its restarted.

Suggested Fix

  1. Error Detection:
    • Check if an input starts with a closing parenthesis during parsing.
    • Display a meaningful error message, e.g., "Invalid input: Input cannot start with a closing parenthesis."
  2. Recovery Mechanism:
    • Ensure the interpreter resets to a functional state after detecting this error.
  3. Testing:
    • Add test cases for inputs starting with ) to verify proper error handling and system recovery.

Additional Notes

This issue significantly affects usability, particularly for new users. Ensuring robust error handling for this edge case will improve the interpreter's reliability and user experience.

@TeamSPoon
Copy link
Collaborator Author

stassa added a commit that referenced this issue Dec 9, 2024
* Fix for issue 204: #204
* Previously, when an unmatched ')' was entered the repl would just
  hang. With the changes in this commit it will raise a warning and
  restart, printing the mettalog prompt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants