Skip to content

Conversation

@nickelization
Copy link
Contributor

This adds the ability to set the TTL flag on riakc_obj records, which can then be used by the sweeper to expire objects on the Riak side of things.

{ok, TTL} ->
TTL;
error ->
false

Choose a reason for hiding this comment

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

Return value disagrees with -spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh, very weird. I wonder why dialyzer didn't catch that. Seems really obvious, and I don't see any ignore-warnings files either. I'll fix the spec but I'm also going to try and spend a little time figuring out why dialyzer is not flagging that code....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, so it seems this is one of those cases where dialyzer doesn't yell at you unless you add certain non-default warning flags that are prone to yielding false positives. If you add the -Wspecdiffs flag, it will tell you:

Type specification riakc_obj:get_ttl(metadata()) -> ttl() | 'undefined' is a subtype of the success typing: riakc_obj:get_ttl(dict()) -> any() 

Which is technically true: that dict we pass in could contain anything, so technically that function could return undefined, just like the spec says.

On the other hand, I'm not sure why it doesn't complain about the clause that returns false being outside the type spec. I suspect that dialyzer may optimistically assume that we'll never call that function in a way that hits the error case, unless it can specifically find a place where we force it to take that branch. Then again, I'm not sure if it can verify that, since I don't know if the dict API specs are specific enough for it to determine that in any scenario.

I can at least get it to throw an error by adding the line false = get_ttl(dict:new()) elsewhere in the module, in which case it complains:

The pattern 'false' can never match the type 'undefined' | non_neg_integer() 
@tburghart
Copy link

riakc_obj:get_ttl/1 should be generating a dialyzer error, this should not be passing all checks.

@thumbot
Copy link

thumbot commented Jan 10, 2017

sweeper-develop-merge 6856c0a ➡️ develop 262e9ad ✅ completed
Looks good! 👍
✅ MERGE

Started at: 2017-01-10 08:07
Duration: 1 seconds.
Result: OK
Message: Merge Success: sweeper-develop-merge 6856c0a onto target branch: develop 262e9ad
Exit Code: OK

📄

 Updating 262e9ad..6856c0a Fast-forward (no commit created; -m option ignored) src/riakc_obj.erl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 

@JeetKunDoug
Copy link

+1

@nickelization nickelization merged commit d5d4150 into develop Jan 10, 2017
@nickelization nickelization deleted the sweeper-develop-merge branch January 10, 2017 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants