-
Notifications
You must be signed in to change notification settings - Fork 12
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 bug when writing to foreign proc #771
Conversation
Moving back into draft to address #770, since it is a highly related issue. |
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.
LGTM, didn't go through the test cases, just skimmed
var initialData = map[string][]string{ | ||
"satoshi": {"hello world", "goodbye world", "buy $btc to grow laser eyes"}, | ||
"zeus": {"i am zeus", "i am the god of thunder", "i am the god of lightning"}, | ||
"wendys_drive_through_lady": {"hi how can I help you", "no I don't know what the federal reserve is", "sir this is a wendys"}, |
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.
lol
parse/analyze.go
Outdated
returns2, ok := p0.Call.Accept(p).([]*types.DataType) | ||
if !ok { | ||
p.errs.AddErr(p0.Call, ErrType, "expected function/procedure to return one or more variables") | ||
} else if returns2, ok := returnVal.([]*types.DataType); ok { |
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.
probably should consider refactor this using switch?
parse/analyze.go
Outdated
|
||
_, ok = e.Accept(s).(*returnsTable) |
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.
looks like you can refactor this function switch
foreign: `foreign procedure do_something()`, | ||
otherProc: `procedure call_foreign() public { | ||
do_something['%s', 'delete_users'](); | ||
}`, |
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.
what's the expected result? expect no err and no outputs?
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.
nothing. No error and no outputs, as the procedure should be successful and it does not return anything.
wantErr: "requires 1 arg(s)", | ||
}, | ||
{ | ||
name: "foreign procedure returns 1 arg, implementation returns none", |
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.
As you pointed out, the test name since here are less confusing. It would be better we change above test case name
Ok I addressed the changes @Yaiba |
updated comment fix bugs on foreign procedures fix build tag fixed act test addressed gavins feedback fix failing unit test
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.
LGTM
This PR fixes several bugs, as well as adds better error messages and adds many tests for foreign procedures.
It fixes the bug found by @KwilLuke where writing data to a foreign procedure failed, as well as #770. It adds tests for both of them. It also adds many negative test cases to check for error messages thrown during runtime.