-
Notifications
You must be signed in to change notification settings - Fork 20
Enable experimental non-null #181
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
base: master
Are you sure you want to change the base?
Changes from all commits
8efcf9e
8037fbf
f1070a2
c1939a7
89467cd
623bd0f
845f528
f1b0ab9
22d6796
153e1e7
5447410
ea965aa
fad5671
005d40e
ca384da
695f3a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,10 +46,10 @@ namespace Valum.ContentNegotiation { | |
if (param_end == -1) | ||
param_end = header.length; | ||
|
||
var @params = Soup.header_parse_semi_param_list (header[param_start:param_end]); | ||
HashTable<string, string?> @params = Soup.header_parse_semi_param_list (header[param_start:param_end]); | ||
|
||
double qvalue; | ||
if (double.try_parse (@params["q"] ?? "1", out qvalue)) { | ||
if (double.try_parse ((!) (@params["q"] ?? "1"), out qvalue)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should try something like follow to avoid the string q = @params["q"] ?? "1";
if (double.try_parse (q, out qvalue) { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return qvalue.clamp (0, 1); | ||
} | ||
|
||
|
@@ -83,7 +83,7 @@ namespace Valum.ContentNegotiation { | |
EqualFunc<string> match = (EqualFunc<string>) Soup.str_case_equal) { | ||
var _expectations = Soup.header_parse_quality_list (expectations, null); | ||
return (req, res, next, ctx) => { | ||
var header = req.headers.get_list (header_name); | ||
string? header = req.headers.get_list (header_name); | ||
if (_expectations.length () == 0) | ||
throw new ClientError.NOT_ACCEPTABLE ("'%s' cannot be satisfied: nothing is expected", header_name); | ||
if (header == null) { | ||
|
@@ -92,9 +92,9 @@ namespace Valum.ContentNegotiation { | |
|
||
string? best_expectation = null; | ||
double best_qvalue = 0; | ||
foreach (var accepted in Soup.header_parse_quality_list (header, null)) { | ||
foreach (var accepted in Soup.header_parse_quality_list ((!) header, null)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed this (added a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I rebase from master then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could help, but it's easy to merge. You should squash all the fixes in a single commit. This can go on forever ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you prefer to merge a single commit? I went with a bunch of smaller commits so that the commit messages could accurately describe the changes; I thought it might make the review process a bit easier. But I'm certainly not averse to squashing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiple commits is fine for reviewing; I'll squash on the merge. It's almost always a matter of history readability and ability to revert changes efficiently. If all the fixes are spread among dozens of commits, it makes both criteria hard to satisfy. |
||
foreach (var expectation in _expectations) { | ||
var current_qvalue = _qvalue_for_param (header, accepted) * _qvalue_for_param (expectations, expectation); | ||
var current_qvalue = _qvalue_for_param ((!) header, accepted) * _qvalue_for_param (expectations, expectation); | ||
if (match (accepted, expectation) && current_qvalue > best_qvalue) { | ||
best_expectation = expectation; | ||
best_qvalue = current_qvalue; | ||
|
@@ -103,7 +103,7 @@ namespace Valum.ContentNegotiation { | |
} | ||
|
||
if (best_expectation != null) { | ||
return forward (req, res, next, ctx, best_expectation); | ||
return forward (req, res, next, ctx, (!) best_expectation); | ||
} | ||
|
||
throw new ClientError.NOT_ACCEPTABLE ("'%s' is not satisfiable by any of '%s'.", | ||
|
@@ -152,7 +152,7 @@ namespace Valum.ContentNegotiation { | |
owned NegotiateCallback forward) { | ||
return negotiate ("Accept-Charset", charsets, (req, res, next, ctx, charset) => { | ||
HashTable<string, string> @params; | ||
var content_type = res.headers.get_content_type (out @params) ?? "application/octet-stream"; | ||
var content_type = (!) ((string?) res.headers.get_content_type (out @params) ?? "application/octet-stream"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure that if you introduce the type, it will not warn for nullable: string content_type = ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like coalesed expressions nullability is just not infered. I might try to patch that in valac, it does not look too difficult. |
||
@params["charset"] = charset; | ||
res.headers.set_content_type (content_type, @params); | ||
return forward (req, res, next, ctx, charset); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,8 @@ namespace Valum { | |
if (/\(\?<(\w+)>.+?\)/.match (regex.get_pattern (), 0, out capture_match_info)) { | ||
try { | ||
do { | ||
captures.append (capture_match_info.fetch (1)); | ||
if (capture_match_info.fetch (1) != null) | ||
captures.append ((!) capture_match_info.fetch (1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the capture is |
||
} while (capture_match_info.next ()); | ||
} catch (RegexError err) { | ||
// ... | ||
|
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.
Is it necessary to get rid of
var
here?