authorgravatar for manlio.perillo@gmail.comManlio Perillo <manlio.perillo@gmail.com> 2022-12-12 09:03:51+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-13 15:00:42-05:00
log89a9e927ad97bf1ef5f45a0a004dd2d46390e441
treef92edbd710b92884e43f1dab502c0bb3fa3ab010
parent1d5368fa35740f64d81f755588edc5c6698036ec

langref: improve the test_fn_reflection.zig doctest

Currently, the test_fn_reflection.zig doctest has an example of .Fn.is_var_args. This example can confuse the reader, since there is no documentation about variadic functions and is_var_args is mainly used in the compiler. Remove the example with .Fn.is_var_args and add instead examples with .Fn.return_type and .Fn.is_generic.

1 files changed, 7 insertions(+), 3 deletions(-)

doc/langref.html.in+7-3
...@@ -5246,11 +5246,15 @@ test "fn type inference" {...@@ -5246,11 +5246,15 @@ test "fn type inference" {
5246 {#header_close#}5246 {#header_close#}
5247 {#header_open|Function Reflection#}5247 {#header_open|Function Reflection#}
5248 {#code_begin|test|test_fn_reflection#}5248 {#code_begin|test|test_fn_reflection#}
5249const expect = @import("std").testing.expect;5249const std = @import("std");
5250const math = std.math;
5251const testing = std.testing;
52505252
5251test "fn reflection" {5253test "fn reflection" {
5252 try expect(@typeInfo(@TypeOf(expect)).Fn.args[0].arg_type.? == bool);5254 try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.args[0].arg_type.? == bool);
5253 try expect(@typeInfo(@TypeOf(expect)).Fn.is_var_args == false);5255 try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir);
5256
5257 try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic);
5254}5258}
5255 {#code_end#}5259 {#code_end#}
5256 {#header_close#}5260 {#header_close#}