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

Adds diagnostic if no return statement found in function #1299

Open
wants to merge 1 commit into
base: release-1.0.0
Choose a base branch
from

Conversation

markwpearce
Copy link
Collaborator

image

If a function explicitly says it will return something, ensure there is a return statement.

This could be improved by checking all branches.

I know there's a BSLint option that basically checks the same thing, but if you don't have a return statement when you say you're going to return a string or an integer, it will crash.

@markwpearce markwpearce added this to the v1.0.0 milestone Sep 10, 2024
@@ -2239,6 +2239,95 @@ describe('ScopeValidator', () => {
});
});

describe('expectedReturnStatement', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need tests for sub as <returnType> as well. This is valid code and works:

sub getName() as string
  return "bob"
end sub

Missing return in sub as <returnType> crashes like function.

image

image

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