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

ast, builder, checker, parser: fix typos #18480

Merged
merged 1 commit into from
Jun 18, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions vlib/v/ast/ast.v
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pub:
mod string
name string
is_pub bool
is_markused bool // an explict `[markused]` tag; the const will NOT be removed by `-skip-unused`, no matter what
is_markused bool // an explicit `[markused]` tag; the const will NOT be removed by `-skip-unused`, no matter what
pos token.Pos
pub mut:
expr Expr // the value expr of field; everything after `=`
Expand Down Expand Up @@ -520,7 +520,7 @@ pub:
is_exported bool // true for `[export: 'exact_C_name']`
is_keep_alive bool // passed memory must not be freed (by GC) before function returns
is_unsafe bool // true, when [unsafe] is used on a fn
is_markused bool // true, when an explict `[markused]` tag was put on a fn; `-skip-unused` will not remove that fn
is_markused bool // true, when an explicit `[markused]` tag was put on a fn; `-skip-unused` will not remove that fn
is_file_translated bool // true, when the file it resides in is `[translated]`
receiver StructField // TODO this is not a struct field
receiver_pos token.Pos // `(u User)` in `fn (u User) name()` position
Expand Down Expand Up @@ -790,7 +790,7 @@ pub mut:
// (for setting the position after the or block for autofree)
is_or bool // `x := foo() or { ... }`
is_tmp bool // for tmp for loop vars, so that autofree can skip them
is_auto_heap bool // value whoes address goes out of scope
is_auto_heap bool // value whose address goes out of scope
is_stack_obj bool // may be pointer to stack value (`mut` or `&` arg and not [heap] struct)
}

Expand Down Expand Up @@ -818,7 +818,7 @@ pub:
has_expr bool
pos token.Pos
typ_pos token.Pos
is_markused bool // an explict `[markused]` tag; the global will NOT be removed by `-skip-unused`
is_markused bool // an explicit `[markused]` tag; the global will NOT be removed by `-skip-unused`
is_volatile bool
pub mut:
expr Expr
Expand Down Expand Up @@ -870,7 +870,7 @@ pub mut:
scope &Scope = unsafe { nil }
stmts []Stmt // all the statements in the source file
imports []Import // all the imports
auto_imports []string // imports that were implicitely added
auto_imports []string // imports that were implicitly added
embedded_files []EmbeddedFile // list of files to embed in the binary
imported_symbols map[string]string // used for `import {symbol}`, it maps symbol => module.symbol
errors []errors.Error // all the checker errors in the file
Expand Down Expand Up @@ -1566,7 +1566,7 @@ pub mut:
index AsmArg // gpr
}

// adressing modes:
// addressing modes:
pub enum AddressingMode {
invalid
displacement // displacement
Expand Down Expand Up @@ -1621,7 +1621,7 @@ pub const (
}
// no comments because maps do not support comments
// r#*: gp registers added in 64-bit extensions, can only be from 8-15 actually
// *mm#: vector/simd registors
// *mm#: vector/simd registers
// st#: floating point numbers
// cr#: control/status registers
// dr#: debug registers
Expand Down Expand Up @@ -1945,7 +1945,7 @@ pub fn (expr Expr) is_blank_ident() bool {
pub fn (expr Expr) pos() token.Pos {
// all uncommented have to be implemented
// Note: please do not print here. the language server will hang
// as it uses STDIO primarly to communicate ~Ned
// as it uses STDIO primarily to communicate ~Ned
match expr {
AnonFn {
return expr.decl.pos
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/ast/table.v
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ pub fn (t &Table) known_type_names() []string {

// has_deep_child_no_ref returns true if type is struct and has any child or nested child with the type of the given name
// the given name consists of module and name (`mod.Name`)
// it doesn't care about childs that are references
// it doesn't care about children that are references
pub fn (t &Table) has_deep_child_no_ref(ts &TypeSymbol, name string) bool {
if ts.info is Struct {
for field in ts.info.fields {
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/ast/types.v
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ pub fn (t &Table) type_to_str_using_aliases(typ Type, import_aliases map[string]
}
// Note, that the duplication of code in some of the match branches here
// is VERY deliberate. DO NOT be tempted to use `else {}` instead, because
// that strongly reduces the usefullness of the exhaustive checking that
// that strongly reduces the usefulness of the exhaustive checking that
// match does.
// Using else{} here led to subtle bugs in vfmt discovered *months*
// after the original code was written.
Expand Down Expand Up @@ -1401,7 +1401,7 @@ fn (t Table) shorten_user_defined_typenames(originalname string, import_aliases
} else {
// FIXME: clean this case and remove the following if
// because it is an hack to format well the type when
// there is a []modul.name
// there is a []mod.name
if res.contains('[]') {
idx := res.index('.') or { -1 }
return res[idx + 1..]
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/builder/builder.v
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub fn (mut b Builder) parse_imports() {
// parsed (but not all of them), then this will cause a problem.
// we could add a list of parsed files instead, but I think
// there is a better solution all around, I will revisit this.
// NOTE: there is a very similar occurance with the way
// NOTE: there is a very similar occurrence with the way
// internal module test's work, and this was the reason there
// were issues with duplicate declarations, so we should sort
// that out in a similar way.
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/builder/cc.v
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ pub fn (mut v Builder) cc() {
mut tcc_output := os.Result{}
original_pwd := os.getwd()
for {
// try to compile with the choosen compiler
// try to compile with the chosen compiler
// if compilation fails, retry again with another
mut ccompiler := v.pref.ccompiler
if v.pref.os == .wasm32 {
Expand Down
10 changes: 5 additions & 5 deletions vlib/v/builder/rebuilding.v
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ fn (mut b Builder) rebuild_cached_module(vexe string, imp_path string) string {
println('Cached ${imp_path} .o file not found... Building .o file for ${imp_path}')
}
b.v_build_module(vexe, imp_path)
rebuilded_o := b.pref.cache_manager.mod_exists(imp_path, '.o', imp_path) or {
rebuilt_o := b.pref.cache_manager.mod_exists(imp_path, '.o', imp_path) or {
panic('could not rebuild cache module for ${imp_path}, error: ${err.msg()}')
}
return rebuilded_o
return rebuilt_o
}
return res
}
Expand All @@ -227,8 +227,8 @@ fn (mut b Builder) handle_usecache(vexe string) {
for imp_stmt in ast_file.imports {
imp := imp_stmt.mod
// strconv is already imported inside builtin, so skip generating its object file
// TODO: incase we have other modules with the same name, make sure they are vlib
// is this even doign anything?
// TODO: in case we have other modules with the same name, make sure they are vlib
// is this even doing anything?
if util.module_is_builtin(imp) {
continue
}
Expand All @@ -240,7 +240,7 @@ fn (mut b Builder) handle_usecache(vexe string) {
}
// The problem is cmd/v is in module main and imports
// the relative module named help, which is built as cmd.v.help not help
// currently this got this workign by building into main, see ast.FnDecl in cgen
// currently this got this working by building into main, see ast.FnDecl in cgen
if imp == 'help' {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/check_types.v
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ fn (mut c Checker) check_shift(mut node ast.InfixExpr, left_type_ ast.Type, righ
match node.op {
.left_shift, .right_shift, .unsigned_right_shift {
// The following code tries to disallow C UBs and IDs at the V level.
// From the C++ standart (see https://pvs-studio.com/en/docs/warnings/v610/):
// From the C++ standard (see https://pvs-studio.com/en/docs/warnings/v610/):
// 1. The type of the result is that of the promoted left operand.
// The behavior is undefined (UB), if the right operand is negative,
// or greater than or equal to the length in bits of the promoted left operand.
Expand Down
8 changes: 4 additions & 4 deletions vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ fn (mut c Checker) asm_arg(arg ast.AsmArg, stmt ast.AsmStmt, aliases []string) {
c.asm_arg(arg.base, stmt, aliases)
c.asm_arg(arg.index, stmt, aliases)
}
ast.BoolLiteral {} // all of these are guarented to be correct.
ast.BoolLiteral {} // all of these are guaranteed to be correct.
ast.FloatLiteral {}
ast.CharLiteral {}
ast.IntegerLiteral {}
Expand Down Expand Up @@ -4012,7 +4012,7 @@ fn (mut c Checker) prefix_expr(mut node ast.PrefixExpr) ast.Type {
}
// FIXME
// there are currently other issues to investigate if right_type
// is unwraped directly as initialization, so do it here
// is unwrapped directly as initialization, so do it here
if node.op == .minus && !right_sym.is_number() {
c.type_error_for_operator('-', 'numeric', right_sym.name, node.pos)
}
Expand Down Expand Up @@ -4402,7 +4402,7 @@ fn (c &Checker) check_struct_signature(from ast.Struct, to ast.Struct) bool {
}
counterpart := filtered[0]
if field.typ != counterpart.typ {
// field has different tye
// field has different type
return false
}
if field.is_pub != counterpart.is_pub {
Expand Down Expand Up @@ -4615,7 +4615,7 @@ fn (mut c Checker) ensure_type_exists(typ ast.Type, pos token.Pos) ? {
}
.int_literal, .float_literal {
// Separate error condition for `int_literal` and `float_literal` because `util.suggestion` may give different
// suggestions due to f32 comparision issue.
// suggestions due to f32 comparison issue.
if !c.is_builtin_mod {
msg := if sym.kind == .int_literal {
'unknown type `${sym.name}`.\nDid you mean `int`?'
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/checker/containers.v
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type {
}
// `a = []`
if node.exprs.len == 0 {
// `a := fn_returing_opt_array() or { [] }`
// `a := fn_returning_opt_array() or { [] }`
if c.expected_type == ast.void_type && c.expected_or_type != ast.void_type {
c.expected_type = c.expected_or_type
}
Expand All @@ -128,7 +128,7 @@ fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type {
}
array_info := type_sym.array_info()
node.elem_type = array_info.elem_type
// clear option flag incase of: `fn opt_arr() ?[]int { return [] }`
// clear option flag in case of: `fn opt_arr() ?[]int { return [] }`
return if c.expected_type.has_flag(.shared_f) {
c.expected_type.clear_flag(.shared_f).deref()
} else {
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
}
}
if !found && c.pref.is_vsh {
// TOOD: test this hack more extensively
// TODO: test this hack more extensively
os_name := 'os.${fn_name}'
if f := c.table.find_fn(os_name) {
if f.generic_names.len == node.concrete_types.len {
Expand Down Expand Up @@ -2059,7 +2059,7 @@ fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
arg) or {
// str method, allow type with str method if fn arg is string
// Passing an int or a string array produces a c error here
// Deleting this condition results in propper V error messages
// Deleting this condition results in proper V error messages
// if arg_typ_sym.kind == .string && typ_sym.has_method('str') {
// continue
// }
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/for.v
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn (mut c Checker) for_stmt(mut node ast.ForStmt) {
}
}
// TODO: update loop var type
// how does this work currenly?
// how does this work currently?
c.check_loop_label(node.label, node.pos)
c.stmts(node.stmts)
c.loop_label = prev_loop_label
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/infix.v
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
unalias_right_type := c.table.unalias_num_type(unwrapped_right_type)
mut promoted_type := c.promote_keeping_aliases(unaliased_left_type, unalias_right_type,
left_sym.kind, right_sym.kind)
// substract pointers is allowed in unsafe block
// subtract pointers is allowed in unsafe block
is_allowed_pointer_arithmetic := left_type.is_any_kind_of_pointer()
&& right_type.is_any_kind_of_pointer() && node.op == .minus
if is_allowed_pointer_arithmetic {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/tests/immutable_deref.vv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ struct Context {}
const ctx_ptr = &Context(unsafe { nil })

fn main() {
// TODO unsafe bug, having this declaration inside `unsafe` results in an erro
// TODO unsafe bug, having this declaration inside `unsafe` results in an error
x := &ctx_ptr
unsafe {
*x = &Context{}
Expand Down
12 changes: 12 additions & 0 deletions vlib/v/checker/tests/import_mod_duplicate_as_alias_err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
vlib/v/checker/tests/import_mod_duplicate_as_alias_err.vv:3:8: error: cannot import `json` into a module with the same name
1 | module json
2 |
3 | import json as vjson
| ~~~~
4 |
5 | const used = true
vlib/v/checker/tests/import_mod_duplicate_as_alias_err.vv:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`)
1 | module json
| ^
2 |
3 | import json as vjson
12 changes: 0 additions & 12 deletions vlib/v/checker/tests/import_mod_duplicate_as_sub_err.out

This file was deleted.

12 changes: 6 additions & 6 deletions vlib/v/checker/tests/struct_init_wrong_warn.vv
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ struct Inner {
ptr &u8
}

struct Outter {
struct Outer {
Inner
mut:
size int
}

fn new_outter() &Outter {
return &Outter{
fn new_outer() &Outer {
return &Outer{
ptr: vcalloc(0)
size: 1
}
}

fn main () {
outter := new_outter()
println(outter)
}
outer := new_outer()
println(outer)
}
4 changes: 2 additions & 2 deletions vlib/v/checker/tests/sum_type_exists.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vlib/v/checker/tests/sum_type_exists.vv:1:22: error: unknown type `Inexistant`
1 | type Miscellaneous = Inexistant | Nope | int
vlib/v/checker/tests/sum_type_exists.vv:1:22: error: unknown type `Inexistent`
1 | type Miscellaneous = Inexistent | Nope | int
| ~~~~~~~~~~
2 changes: 1 addition & 1 deletion vlib/v/checker/tests/sum_type_exists.vv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
type Miscellaneous = Inexistant | Nope | int
type Miscellaneous = Inexistent | Nope | int
6 changes: 3 additions & 3 deletions vlib/v/checker/tests/vweb_routing_checks.out
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
vlib/v/checker/tests/vweb_routing_checks.vv:20:1: warning: mismatched parameters count between vweb method `App.bar` (1) and route attribute ['/bar'] (0)
18 | // segfault because path taks 0 vars and fcn takes 1 arg
18 | // segfault because path takes 0 vars and fcn takes 1 arg
19 | ['/bar']
20 | pub fn (mut app App) bar(a string) vweb.Result {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21 | return app.html('works')
22 | }
vlib/v/checker/tests/vweb_routing_checks.vv:26:1: warning: mismatched parameters count between vweb method `App.cow` (0) and route attribute ['/cow/:low'] (1)
24 | // no segfault, but it shouldnt compile
24 | // no segfault, but it shouldn't compile
25 | ['/cow/:low']
26 | pub fn (mut app App) cow() vweb.Result {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 | return app.html('works')
28 | }
28 | }
4 changes: 2 additions & 2 deletions vlib/v/checker/tests/vweb_routing_checks.vv
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ pub fn (mut app App) foo(a string) vweb.Result {
return app.html('works')
}

// segfault because path taks 0 vars and fcn takes 1 arg
// segfault because path takes 0 vars and fcn takes 1 arg
['/bar']
pub fn (mut app App) bar(a string) vweb.Result {
return app.html('works')
}

// no segfault, but it shouldnt compile
// no segfault, but it shouldn't compile
['/cow/:low']
pub fn (mut app App) cow() vweb.Result {
return app.html('works')
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/parser/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
}
// the tmpl inherits all parent scopes. previous functionality was just to
// inherit the scope from which the comptime call was made and no parents.
// this is much simpler and allws access to globals. can be changed if needed.
// this is much simpler and allows access to globals. can be changed if needed.
mut file := parse_comptime(tmpl_path, v_code, p.table, p.pref, p.scope)
file.path = tmpl_path
return ast.ComptimeCall{
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/parser/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ run them via `v file.v` instead',
if file_mode == .v && existing.file_mode != .v {
// a definition made in a .c.v file, should have a priority over a .v file definition of the same function
if !p.pref.is_fmt {
name = p.prepend_mod('pure_v_but_overriden_by_${existing.file_mode}_${short_fn_name}')
name = p.prepend_mod('pure_v_but_overridden_by_${existing.file_mode}_${short_fn_name}')
}
} else {
p.table.redefined_fns << name
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/parser/parse_type.v
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ fn (mut p Parser) parse_generic_inst_type(name string) ast.Type {
p.error_with_pos('interface `${parent_sym.name}` is not a generic interface, cannot instantiate to the concrete types',
concrete_types_pos)
} else if parent_sym.info.generic_types.len != concrete_types.len {
p.error_with_pos('the number of generic types of interfce `${parent_sym.name}` is inconsistent with the concrete types',
p.error_with_pos('the number of generic types of interface `${parent_sym.name}` is inconsistent with the concrete types',
concrete_types_pos)
}
}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/parser/parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ fn (mut p Parser) asm_ios(output bool) []ast.AsmIO {
} else if mut expr is ast.Ident {
alias = expr.name
}
// for constraints like `a`, no alias is needed, it is reffered to as rcx
// for constraints like `a`, no alias is needed, it is referred to as rcx
mut comments := []ast.Comment{}
for p.tok.kind == .comment {
comments << p.comment()
Expand Down