diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-01-25 04:10:11 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-01-25 04:10:11 -0500 |
| commit | 3671582c15235e5f79a84936ea2f834f6968ff8c (patch) | |
| tree | 7fa2c7f06331feaad43ba63b0969add120633d49 /src/analyze.cpp | |
| parent | e5bc5873d74713bedbc32817ed31370c3256418d (diff) | |
| download | zig-3671582c15235e5f79a84936ea2f834f6968ff8c.tar.gz zig-3671582c15235e5f79a84936ea2f834f6968ff8c.zip | |
syntax: functions require return type. remove `->`
The purpose of this is:
* Only one way to do things
* Changing a function with void return type to return a possible
error becomes a 1 character change, subtly encouraging
people to use errors.
See #632
Here are some imperfect sed commands for performing this update:
remove arrow:
```
sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig")
```
add void:
```
sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig")
```
Some cleanup may be necessary, but this should do the bulk of the work.
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 1880b71fbb..49f8e093a0 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -918,9 +918,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) { if (fn_type_id->alignment != 0) { buf_appendf(&fn_type->name, " align(%" PRIu32 ")", fn_type_id->alignment); } - if (fn_type_id->return_type->id != TypeTableEntryIdVoid) { - buf_appendf(&fn_type->name, " -> %s", buf_ptr(&fn_type_id->return_type->name)); - } + buf_appendf(&fn_type->name, " %s", buf_ptr(&fn_type_id->return_type->name)); skip_debug_info = skip_debug_info || !fn_type_id->return_type->di_type; // next, loop over the parameters again and compute debug information @@ -1082,7 +1080,7 @@ TypeTableEntry *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) { const char *comma_str = (i == 0) ? "" : ","; buf_appendf(&fn_type->name, "%svar", comma_str); } - buf_appendf(&fn_type->name, ")->var"); + buf_appendf(&fn_type->name, ")var"); fn_type->data.fn.fn_type_id = *fn_type_id; fn_type->data.fn.is_generic = true; @@ -2665,7 +2663,7 @@ static bool scope_is_root_decls(Scope *scope) { static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, TypeTableEntry *fn_type) { add_node_error(g, proto_node, - buf_sprintf("expected 'fn([]const u8, ?&builtin.StackTrace) -> unreachable', found '%s'", + buf_sprintf("expected 'fn([]const u8, ?&builtin.StackTrace) unreachable', found '%s'", buf_ptr(&fn_type->name))); } |
