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

Fix assigning RTIME literal to RTIME variable #226

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

MasonM
Copy link
Collaborator

@MasonM MasonM commented Dec 11, 2023

Currently, trying to assign an RTIME literal to an RTIME variable (e.g. beresp.ttl) triggers the error "RTIME literal could not assign to RTIME". However, the linter allows this:

falco/linter/operator.go

Lines 56 to 60 in 87715d6

case types.RTimeType, types.TimeType:
switch right {
// allows both variable and literal
case types.RTimeType, types.TimeType:
return

I double-checked using Fiddle: https://fiddle.fastly.dev/fiddle/fe4fb73d

Currently, trying to assign an RTIME literal to an RTIME variable (e.g.
`beresp.ttl`) triggers the error "RTIME literal could not assign to
RTIME". However, the linter allows this:
https://github.com/ysugimoto/falco/blob/87715d639b5e292cce09cb63a0fbdb8276f3e038/linter/operator.go#L56-L60

I double-checked using Fiddle: https://fiddle.fastly.dev/fiddle/fe4fb73d
@richardmarshall
Copy link
Collaborator

TIME variables should also be able to have a RTIME literal assigned, could you fix that too?

if right.IsLiteral() {
return errors.WithStack(fmt.Errorf("RTIME literal could not assign to TIME"))
}

Validity of that assignment shown here: https://fiddle.fastly.dev/fiddle/f663accf

@MasonM
Copy link
Collaborator Author

MasonM commented Dec 12, 2023

@richardmarshall You're right! Done in 9a9ec61

Copy link
Collaborator

@richardmarshall richardmarshall left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Owner

@ysugimoto ysugimoto left a comment

Choose a reason for hiding this comment

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

Thanks both, looks very good!

@ysugimoto ysugimoto merged commit 2d994ab into ysugimoto:main Dec 13, 2023
1 check passed
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.

3 participants