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

Allows subroutine calls in return statments #384

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gabrielg
Copy link

Not sure why this check was added, but Fastly, as of writing, does allow subroutine calls in returns. For example, see these subroutines defined in init:

sub return_test_str STRING {
	return std.toupper("test");
}

sub return_test_bool BOOL {
	return randombool(1, 2);
}

These can be called from vcl_recv successfully like so:

declare local var.strret STRING;
declare local var.boolret BOOL;

set var.strret = return_test_str();
set var.boolret = return_test_bool();

log "testing returns: " var.strret ", " var.boolret;

Here's an example Fiddle: https://fiddle.fastly.dev/fiddle/b872e5de


Has Fastly's behaviour perhaps changed recently and Falco is reflecting a previous behaviour?

Not sure why this check was added, but Fastly, as of writing, _does_
allow subroutine calls in returns. For example, see these subroutines
defined in `init`:

	sub return_test_str STRING {
		return std.toupper("test");
	}

	sub return_test_bool BOOL {
		return randombool(1, 2);
	}

These can be called from `vcl_recv` successfully like so:

	declare local var.strret STRING;
	declare local var.boolret BOOL;

	set var.strret = return_test_str();
	set var.boolret = return_test_bool();

	log "testing returns: " var.strret ", " var.boolret;

Here's an example Fiddle: https://fiddle.fastly.dev/fiddle/b872e5de
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.

1 participant