diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 25f80eaa79..2505b91129 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -506,12 +506,12 @@ pub fn (a []char) index(v char) int { // []int.reduce executes a given reducer function on each element of the array, // resulting in a single output value. pub fn (a []int) reduce(iter fn(accum, curr int)int, accum_start int) int { - mut _accum := accum_start + mut accum_ := accum_start for i in a { - _accum = iter(_accum, i) + accum_ = iter(accum_, i) } - return _accum + return accum_ } // array_eq checks if two arrays contain all the same elements in the same order. diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index aaf367dc86..a7e7e07205 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -757,9 +757,9 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) { is_main := it.name == 'main' if is_main { if g.pref.os == .windows { - g.write('int wmain(int argc, wchar_t *argv[], wchar_t *envp[]') + g.write('int wmain(int __argc, wchar_t *__argv[], wchar_t *__envp[]') } else { - g.write('int ${it.name}(int argc, char** argv') + g.write('int ${it.name}(int __argc, char** __argv') } } else { @@ -817,9 +817,9 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) { g.writeln('free(_const_os__args.data); // empty, inited in _vinit()') } if g.pref.os == .windows { - g.writeln('_const_os__args = os__init_os_args_wide(argc, argv);') + g.writeln('_const_os__args = os__init_os_args_wide(__argc, __argv);') } else { - g.writeln('_const_os__args = os__init_os_args(argc, (byteptr*)argv);') + g.writeln('_const_os__args = os__init_os_args(__argc, (byteptr*)__argv);') } } } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index aed3b6e0c8..2f77cda034 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1686,6 +1686,9 @@ fn (p mut Parser) assign_stmt() ast.Stmt { p.error('unknown variable `$ident.name`') } if is_decl && ident.kind != .blank_ident { + if ident.name.starts_with('__') { + p.error('variable names cannot start with `__`') + } if p.scope.known_var(ident.name) { p.error('redefinition of `$ident.name`') }