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

Add forward compatibility for changing HTTPServerRequest from class to struct #2534

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions web/vibe/web/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -1256,11 +1256,11 @@ package void setVoid(T, U)(ref T dst, U value)
}

unittest {
static assert(!__traits(compiles, { bool[] barr; ParamError err;readFormParamRec(null, barr, "f", true, NestedNameStyle.d, err); }));
static assert(__traits(compiles, { bool[2] barr; ParamError err;readFormParamRec(null, barr, "f", true, NestedNameStyle.d, err); }));
static assert(!__traits(compiles, { bool[] barr; ParamError err;readFormParamRec(HTTPServerRequest.init, barr, "f", true, NestedNameStyle.d, err); }));
static assert(__traits(compiles, { bool[2] barr; ParamError err;readFormParamRec(HTTPServerRequest.init, barr, "f", true, NestedNameStyle.d, err); }));

enum Test: string { a = "AAA", b="BBB" }
static assert(__traits(compiles, { Test barr; ParamError err;readFormParamRec(null, barr, "f", true, NestedNameStyle.d, err); }));
static assert(__traits(compiles, { Test barr; ParamError err;readFormParamRec(HTTPServerRequest.init, barr, "f", true, NestedNameStyle.d, err); }));
}

private string getArrayFieldName(T)(NestedNameStyle style, string prefix, T index)
Expand Down
4 changes: 2 additions & 2 deletions web/vibe/web/i18n.d
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ package string determineLanguage(alias METHOD)(scope HTTPServerRequest req)

unittest { // make sure that the custom determineLanguage is called
static struct CTX {
static string determineLanguage(Object a) { return "test"; }
static string determineLanguage(HTTPServerRequest a) { return "test"; }
}
@translationContext!CTX
static class Test {
Expand All @@ -350,7 +350,7 @@ unittest { // make sure that the custom determineLanguage is called
}
}
auto test = new Test;
assert(determineLanguage!(test.test)(null) == "test");
assert(determineLanguage!(test.test)(HTTPServerRequest.init) == "test");
}

unittest { // issue #1955
Expand Down
2 changes: 1 addition & 1 deletion web/vibe/web/web.d
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ private struct RequestContext {

private RequestContext getRequestContext()
@trusted nothrow {
assert(s_requestContext.req !is null, "Request context used outside of a web interface request!");
assert(s_requestContext.req !is HTTPServerRequest.init, "Request context used outside of a web interface request!");
return s_requestContext;
}

Expand Down
Loading