-
Couldn't load subscription status.
- Fork 38
Add error message if unimplemented subroutines are used #628
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
Add error message if unimplemented subroutines are used #628
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that if an unimplemented subroutine is invoked, a clear error message is displayed and a precompile error is triggered.
- Introduces a dedicated switch block to check for various unimplemented subroutines based on their index in the system table.
- Refactors the code to use a local variable for the literal data for clarity.
cobj/typeck.c
Outdated
| case 2: // CBL_CHANGE_DIR | ||
| case 3: // CBL_CHECK_FILE_EXIST | ||
| case 4: // CBL_CLOSE_FILE | ||
| case 5: // CBL_COPY_FILE | ||
| case 6: // CBL_CREATE_DIR | ||
| case 7: // CBL_CREATE_FILE | ||
| case 8: // CBL_DELETE_DIR | ||
| case 9: // CBL_DELETE_FILE | ||
| case 11: // CBL_ERROR_PROC | ||
| case 12: // CBL_EXIT_PROC | ||
| case 13: // CBL_FLUSH_FILE | ||
| case 14: // CBL_GET_CURRENT_DIR | ||
| case 15: // CBL_IMP | ||
| case 20: // CBL_OPEN_FILE | ||
| case 22: // CBL_READ_FILE | ||
| case 23: // CBL_RENAME_FILE | ||
| case 26: // CBL_WRITE_FILE | ||
| case 28: // CBL_OC_KEISEN | ||
| case 29: // CBL_OC_ATTRIBUTE | ||
| case 30: // C$CHDIR | ||
| case 31: // C$COPY | ||
| case 32: // C$DELETE | ||
| case 33: // C$FILEINFO | ||
| case 35: // C$GETPID | ||
| case 36: // C$JUSTIFY | ||
| case 38: // C$MAKEDIR | ||
| case 39: // C$NARG | ||
| case 40: // C$SLEEP | ||
| case 41: // C$PARAMSIZE |
Copilot
AI
Apr 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The switch-case relies on hardcoded index values to identify unimplemented subroutines, which could be error-prone if the 'system_tab' ordering changes. Consider using named constants or an enumeration for these indices to improve code clarity and maintainability.
| case 2: // CBL_CHANGE_DIR | |
| case 3: // CBL_CHECK_FILE_EXIST | |
| case 4: // CBL_CLOSE_FILE | |
| case 5: // CBL_COPY_FILE | |
| case 6: // CBL_CREATE_DIR | |
| case 7: // CBL_CREATE_FILE | |
| case 8: // CBL_DELETE_DIR | |
| case 9: // CBL_DELETE_FILE | |
| case 11: // CBL_ERROR_PROC | |
| case 12: // CBL_EXIT_PROC | |
| case 13: // CBL_FLUSH_FILE | |
| case 14: // CBL_GET_CURRENT_DIR | |
| case 15: // CBL_IMP | |
| case 20: // CBL_OPEN_FILE | |
| case 22: // CBL_READ_FILE | |
| case 23: // CBL_RENAME_FILE | |
| case 26: // CBL_WRITE_FILE | |
| case 28: // CBL_OC_KEISEN | |
| case 29: // CBL_OC_ATTRIBUTE | |
| case 30: // C$CHDIR | |
| case 31: // C$COPY | |
| case 32: // C$DELETE | |
| case 33: // C$FILEINFO | |
| case 35: // C$GETPID | |
| case 36: // C$JUSTIFY | |
| case 38: // C$MAKEDIR | |
| case 39: // C$NARG | |
| case 40: // C$SLEEP | |
| case 41: // C$PARAMSIZE | |
| case CBL_CHANGE_DIR: // CBL_CHANGE_DIR | |
| case CBL_CHECK_FILE_EXIST: // CBL_CHECK_FILE_EXIST | |
| case CBL_CLOSE_FILE: // CBL_CLOSE_FILE | |
| case CBL_COPY_FILE: // CBL_COPY_FILE | |
| case CBL_CREATE_DIR: // CBL_CREATE_DIR | |
| case CBL_CREATE_FILE: // CBL_CREATE_FILE | |
| case CBL_DELETE_DIR: // CBL_DELETE_DIR | |
| case CBL_DELETE_FILE: // CBL_DELETE_FILE | |
| case CBL_ERROR_PROC: // CBL_ERROR_PROC | |
| case CBL_EXIT_PROC: // CBL_EXIT_PROC | |
| case CBL_FLUSH_FILE: // CBL_FLUSH_FILE | |
| case CBL_GET_CURRENT_DIR: // CBL_GET_CURRENT_DIR | |
| case CBL_IMP: // CBL_IMP | |
| case CBL_OPEN_FILE: // CBL_OPEN_FILE | |
| case CBL_READ_FILE: // CBL_READ_FILE | |
| case CBL_RENAME_FILE: // CBL_RENAME_FILE | |
| case CBL_WRITE_FILE: // CBL_WRITE_FILE | |
| case CBL_OC_KEISEN: // CBL_OC_KEISEN | |
| case CBL_OC_ATTRIBUTE: // CBL_OC_ATTRIBUTE | |
| case C$CHDIR: // C$CHDIR | |
| case C$COPY: // C$COPY | |
| case C$DELETE: // C$DELETE | |
| case C$FILEINFO: // C$FILEINFO | |
| case C$GETPID: // C$GETPID | |
| case C$JUSTIFY: // C$JUSTIFY | |
| case C$MAKEDIR: // C$MAKEDIR | |
| case C$NARG: // C$NARG | |
| case C$SLEEP: // C$SLEEP | |
| case C$PARAMSIZE: // C$PARAMSIZE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see another example of kio-watanabe#6
Summary
Fixed that if an unimplemented subroutine is called, an error message is output and a precompile error occurs.
Example
COBOL:
error message: