Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revive etcd-io#19 (as the PR is closed
due to the source repo being deleted by the author, I can only reproduce the commits again) If the code execution flow after the failpoint type conversion doesn't jump to other parts of the code, the `__badType` will be executed, causing irrelevant error messages to be printed. For example, consider the following snippet ```go // gofail: var SomeFuncString string // log.Println("SomeFuncString", SomeFuncString) ``` It will be generated into the following snippet ```go if vSomeFuncString, __fpErr := __fp_SomeFuncString.Acquire(); __fpErr == nil { SomeFuncString, __fpTypeOK := vSomeFuncString.(string) if !__fpTypeOK { goto __badTypeSomeFuncString } log.Println("SomeFuncString", SomeFuncString) __badTypeSomeFuncString: __fp_SomeFuncString.BadType(vSomeFuncString, "string") } ``` As you can see, because `log.println` doesn't jump to other parts of the code, after printing the log, the code will continue to execute `__badTypeSomeFuncString`, thus, printing the following message: `"SomeFuncString" got value Hello_world of type "string" but expected type "string"` The solution is to add a `__nomock` label, in the case of type conversion succeeded, thus the `__badType` label won't be executed. Reference: - demo code https://github.com/henrybear327/gofail-perf-fix-demo/tree/issue/val_error Signed-off-by: Chun-Hung Tseng <[email protected]>
- Loading branch information