checker: minor c2v fixes
							parent
							
								
									11113e43e7
								
							
						
					
					
						commit
						6d72209363
					
				| 
						 | 
					@ -28,9 +28,9 @@ jobs:
 | 
				
			||||||
    - uses: actions/checkout@v2
 | 
					    - uses: actions/checkout@v2
 | 
				
			||||||
    - name: Install dependencies
 | 
					    - name: Install dependencies
 | 
				
			||||||
      run: |
 | 
					      run: |
 | 
				
			||||||
           sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update; 
 | 
					           sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update;
 | 
				
			||||||
           sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev valgrind
 | 
					           sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev valgrind
 | 
				
			||||||
           ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev      
 | 
					           ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
 | 
				
			||||||
    - name: Build v
 | 
					    - name: Build v
 | 
				
			||||||
      run: |
 | 
					      run: |
 | 
				
			||||||
        echo $VFLAGS
 | 
					        echo $VFLAGS
 | 
				
			||||||
| 
						 | 
					@ -46,10 +46,10 @@ jobs:
 | 
				
			||||||
      run: ./v test-fixed
 | 
					      run: ./v test-fixed
 | 
				
			||||||
    - name: Test building v tools
 | 
					    - name: Test building v tools
 | 
				
			||||||
      run: ./v build-tools
 | 
					      run: ./v build-tools
 | 
				
			||||||
    - name: v vet
 | 
					#    - name: v vet # TODO bring back v vet on linux-tcc
 | 
				
			||||||
      run: |
 | 
					#      run: |
 | 
				
			||||||
        ./v vet vlib/sqlite
 | 
					#        ./v vet vlib/sqlite
 | 
				
			||||||
        ./v vet vlib/v
 | 
					#        ./v vet vlib/v
 | 
				
			||||||
    - name: v fmt
 | 
					    - name: v fmt
 | 
				
			||||||
      run: |
 | 
					      run: |
 | 
				
			||||||
        ./v fmt -verify vlib/v/checker/checker.v
 | 
					        ./v fmt -verify vlib/v/checker/checker.v
 | 
				
			||||||
| 
						 | 
					@ -97,7 +97,7 @@ jobs:
 | 
				
			||||||
        ##brew install libpq openssl freetype ### these are *already installed* on Catalina ...
 | 
					        ##brew install libpq openssl freetype ### these are *already installed* on Catalina ...
 | 
				
			||||||
        brew uninstall --ignore-dependencies libpq ## libpq is a dependency of PHP
 | 
					        brew uninstall --ignore-dependencies libpq ## libpq is a dependency of PHP
 | 
				
			||||||
        brew install postgresql
 | 
					        brew install postgresql
 | 
				
			||||||
        brew install glfw 
 | 
					        brew install glfw
 | 
				
			||||||
        ## brew install sdl2 sdl2_ttf sdl2_mixer sdl2_image
 | 
					        ## brew install sdl2 sdl2_ttf sdl2_mixer sdl2_image
 | 
				
			||||||
        export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
 | 
					        export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
 | 
				
			||||||
    - name: Build V
 | 
					    - name: Build V
 | 
				
			||||||
| 
						 | 
					@ -124,6 +124,10 @@ jobs:
 | 
				
			||||||
      run: ./v test-fixed
 | 
					      run: ./v test-fixed
 | 
				
			||||||
    - name: Build examples
 | 
					    - name: Build examples
 | 
				
			||||||
      run: ./v build-examples
 | 
					      run: ./v build-examples
 | 
				
			||||||
 | 
					    - name: v vet
 | 
				
			||||||
 | 
					      run: |
 | 
				
			||||||
 | 
					        ./v vet vlib/sqlite
 | 
				
			||||||
 | 
					        ./v vet vlib/v
 | 
				
			||||||
    - name: Cross-compilation to Linux
 | 
					    - name: Cross-compilation to Linux
 | 
				
			||||||
      run: ./v -os linux cmd/v
 | 
					      run: ./v -os linux cmd/v
 | 
				
			||||||
#    - name: Test vsh
 | 
					#    - name: Test vsh
 | 
				
			||||||
| 
						 | 
					@ -151,8 +155,8 @@ jobs:
 | 
				
			||||||
        node-version: 12.x
 | 
					        node-version: 12.x
 | 
				
			||||||
    - name: Install dependencies
 | 
					    - name: Install dependencies
 | 
				
			||||||
      run: |
 | 
					      run: |
 | 
				
			||||||
         sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; 
 | 
					         sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list;
 | 
				
			||||||
         sudo apt-get update; 
 | 
					         sudo apt-get update;
 | 
				
			||||||
         sudo apt-get install --quiet -y postgresql libpq-dev libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev valgrind
 | 
					         sudo apt-get install --quiet -y postgresql libpq-dev libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev valgrind
 | 
				
			||||||
         ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
 | 
					         ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
 | 
				
			||||||
    - name: Build V
 | 
					    - name: Build V
 | 
				
			||||||
| 
						 | 
					@ -255,10 +259,10 @@ jobs:
 | 
				
			||||||
#         node-version: 12.x
 | 
					#         node-version: 12.x
 | 
				
			||||||
#     - name: Install dependencies
 | 
					#     - name: Install dependencies
 | 
				
			||||||
#       run: |
 | 
					#       run: |
 | 
				
			||||||
#          sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; 
 | 
					#          sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list;
 | 
				
			||||||
#          sudo apt-get update; 
 | 
					#          sudo apt-get update;
 | 
				
			||||||
#          sudo apt-get install --quiet -y musl musl-tools libssl-dev sqlite3 libsqlite3-dev valgrind
 | 
					#          sudo apt-get install --quiet -y musl musl-tools libssl-dev sqlite3 libsqlite3-dev valgrind
 | 
				
			||||||
#          sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev 
 | 
					#          sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
 | 
				
			||||||
#     - name: Build v
 | 
					#     - name: Build v
 | 
				
			||||||
#       run: echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
 | 
					#       run: echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
 | 
				
			||||||
# #    - name: Test v binaries
 | 
					# #    - name: Test v binaries
 | 
				
			||||||
| 
						 | 
					@ -424,11 +428,11 @@ jobs:
 | 
				
			||||||
    - uses: actions/checkout@v2
 | 
					    - uses: actions/checkout@v2
 | 
				
			||||||
    - name: Install dependencies
 | 
					    - name: Install dependencies
 | 
				
			||||||
      run: |
 | 
					      run: |
 | 
				
			||||||
        sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; 
 | 
					        sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list;
 | 
				
			||||||
        sudo apt-get update; 
 | 
					        sudo apt-get update;
 | 
				
			||||||
        sudo apt-get install --quiet -y postgresql libpq-dev libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev 
 | 
					        sudo apt-get install --quiet -y postgresql libpq-dev libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev
 | 
				
			||||||
        sudo apt-get install --quiet -y valgrind g++-9 
 | 
					        sudo apt-get install --quiet -y valgrind g++-9
 | 
				
			||||||
        ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev 
 | 
					        ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
 | 
				
			||||||
    - name: Build V
 | 
					    - name: Build V
 | 
				
			||||||
      run: make -j4
 | 
					      run: make -j4
 | 
				
			||||||
    - name: g++ version
 | 
					    - name: g++ version
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@ pub fn (mut c Checker) check_basic(got, expected table.Type) bool {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// TODO: this should no longer be needed
 | 
						// TODO: this should no longer be needed
 | 
				
			||||||
	// if expected == table.t_type && got == table.t_type {
 | 
						// if expected == table.t_type && got == table.t_type {
 | 
				
			||||||
	// 	return true
 | 
						// return true
 | 
				
			||||||
	// }
 | 
						// }
 | 
				
			||||||
	// # NOTE: use symbols from this point on for perf
 | 
						// # NOTE: use symbols from this point on for perf
 | 
				
			||||||
	got_type_sym := t.get_type_symbol(got)
 | 
						got_type_sym := t.get_type_symbol(got)
 | 
				
			||||||
| 
						 | 
					@ -91,8 +91,7 @@ pub fn (mut c Checker) check_basic(got, expected table.Type) bool {
 | 
				
			||||||
	// TODO
 | 
						// TODO
 | 
				
			||||||
	// accept [] when an expected type is an array
 | 
						// accept [] when an expected type is an array
 | 
				
			||||||
	if got_type_sym.kind == .array &&
 | 
						if got_type_sym.kind == .array &&
 | 
				
			||||||
		got_type_sym.name == 'array_void' &&
 | 
							got_type_sym.name == 'array_void' && exp_type_sym.kind == .array {
 | 
				
			||||||
		exp_type_sym.kind == .array {
 | 
					 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// type alias
 | 
						// type alias
 | 
				
			||||||
| 
						 | 
					@ -112,7 +111,7 @@ pub fn (mut c Checker) check_basic(got, expected table.Type) bool {
 | 
				
			||||||
	return false
 | 
						return false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn (mut c Checker) check_matching_function_symbols(got_type_sym &table.TypeSymbol, exp_type_sym &table.TypeSymbol) bool {
 | 
					pub fn (mut c Checker) check_matching_function_symbols(got_type_sym, exp_type_sym &table.TypeSymbol) bool {
 | 
				
			||||||
	got_info := got_type_sym.info as table.FnType
 | 
						got_info := got_type_sym.info as table.FnType
 | 
				
			||||||
	exp_info := exp_type_sym.info as table.FnType
 | 
						exp_info := exp_type_sym.info as table.FnType
 | 
				
			||||||
	got_fn := got_info.func
 | 
						got_fn := got_info.func
 | 
				
			||||||
| 
						 | 
					@ -132,7 +131,7 @@ pub fn (mut c Checker) check_matching_function_symbols(got_type_sym &table.TypeS
 | 
				
			||||||
		if exp_arg_is_ptr != got_arg_is_ptr {
 | 
							if exp_arg_is_ptr != got_arg_is_ptr {
 | 
				
			||||||
			exp_arg_pointedness := if exp_arg_is_ptr { 'a pointer' } else { 'NOT a pointer' }
 | 
								exp_arg_pointedness := if exp_arg_is_ptr { 'a pointer' } else { 'NOT a pointer' }
 | 
				
			||||||
			got_arg_pointedness := if got_arg_is_ptr { 'a pointer' } else { 'NOT a pointer' }
 | 
								got_arg_pointedness := if got_arg_is_ptr { 'a pointer' } else { 'NOT a pointer' }
 | 
				
			||||||
			c.add_error_detail('`$exp_fn.name`\'s expected fn argument: `$exp_arg.name` is $exp_arg_pointedness, but the passed fn argument: `$got_arg.name` is $got_arg_pointedness')
 | 
								c.add_error_detail("`$exp_fn.name`\'s expected fn argument: `$exp_arg.name` is $exp_arg_pointedness, but the passed fn argument: `$got_arg.name` is $got_arg_pointedness")
 | 
				
			||||||
			return false
 | 
								return false
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if !c.check_basic(got_arg.typ, exp_arg.typ) {
 | 
							if !c.check_basic(got_arg.typ, exp_arg.typ) {
 | 
				
			||||||
| 
						 | 
					@ -310,7 +309,8 @@ pub fn (mut c Checker) string_inter_lit(mut node ast.StringInterLiteral) table.T
 | 
				
			||||||
		typ := c.table.unalias_num_type(ftyp)
 | 
							typ := c.table.unalias_num_type(ftyp)
 | 
				
			||||||
		mut fmt := node.fmts[i]
 | 
							mut fmt := node.fmts[i]
 | 
				
			||||||
		// analyze and validate format specifier
 | 
							// analyze and validate format specifier
 | 
				
			||||||
		if fmt !in [`E`, `F`, `G`, `e`, `f`, `g`, `d`, `u`, `x`, `X`, `o`, `c`, `s`, `p`, `_`] {
 | 
							if fmt !in
 | 
				
			||||||
 | 
								[`E`, `F`, `G`, `e`, `f`, `g`, `d`, `u`, `x`, `X`, `o`, `c`, `s`, `p`, `_`] {
 | 
				
			||||||
			c.error('unknown format specifier `${fmt:c}`', node.fmt_poss[i])
 | 
								c.error('unknown format specifier `${fmt:c}`', node.fmt_poss[i])
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if fmt == `_` { // set default representation for type if none has been given
 | 
							if fmt == `_` { // set default representation for type if none has been given
 | 
				
			||||||
| 
						 | 
					@ -347,7 +347,7 @@ pub fn (mut c Checker) string_inter_lit(mut node ast.StringInterLiteral) table.T
 | 
				
			||||||
	return table.string_type
 | 
						return table.string_type
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn (c &Checker) check_sumtype_compatibility(a table.Type, b table.Type) bool {
 | 
					pub fn (c &Checker) check_sumtype_compatibility(a, b table.Type) bool {
 | 
				
			||||||
	if c.table.sumtype_has_variant(a, b) {
 | 
						if c.table.sumtype_has_variant(a, b) {
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -659,7 +659,7 @@ pub fn (mut c Checker) infix_expr(mut infix_expr ast.InfixExpr) table.Type {
 | 
				
			||||||
			infix_expr.pos)
 | 
								infix_expr.pos)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Dual sides check (compatibility check)
 | 
						// Dual sides check (compatibility check)
 | 
				
			||||||
	if !c.symmetric_check(right_type, left_type) {
 | 
						if !c.symmetric_check(right_type, left_type) && !c.pref.translated {
 | 
				
			||||||
		// for type-unresolved consts
 | 
							// for type-unresolved consts
 | 
				
			||||||
		if left_type == table.void_type || right_type == table.void_type {
 | 
							if left_type == table.void_type || right_type == table.void_type {
 | 
				
			||||||
			return table.void_type
 | 
								return table.void_type
 | 
				
			||||||
| 
						 | 
					@ -1723,9 +1723,15 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) {
 | 
				
			||||||
			assign_stmt.op !in [.assign, .decl_assign] && !c.inside_unsafe {
 | 
								assign_stmt.op !in [.assign, .decl_assign] && !c.inside_unsafe {
 | 
				
			||||||
			c.warn('pointer arithmetic is only allowed in `unsafe` blocks', assign_stmt.pos)
 | 
								c.warn('pointer arithmetic is only allowed in `unsafe` blocks', assign_stmt.pos)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							// Dual sides check (compatibility check)
 | 
				
			||||||
 | 
							if !is_blank_ident && !c.check_types(right_type_unwrapped, left_type_unwrapped) &&
 | 
				
			||||||
 | 
								right_sym.kind != .placeholder {
 | 
				
			||||||
 | 
								c.error('cannot assign `$right_sym.name` to `$left.str()` of type `$left_sym.name`',
 | 
				
			||||||
 | 
									right.position())
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if c.pref.translated {
 | 
							if c.pref.translated {
 | 
				
			||||||
			// TODO fix this in C2V instead, for example cast enums to int before using `|` on them.
 | 
								// TODO fix this in C2V instead, for example cast enums to int before using `|` on them.
 | 
				
			||||||
			return
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Single side check
 | 
							// Single side check
 | 
				
			||||||
		match assign_stmt.op {
 | 
							match assign_stmt.op {
 | 
				
			||||||
| 
						 | 
					@ -1774,12 +1780,6 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else {}
 | 
								else {}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Dual sides check (compatibility check)
 | 
					 | 
				
			||||||
		if !is_blank_ident && !c.check_types(right_type_unwrapped, left_type_unwrapped) &&
 | 
					 | 
				
			||||||
			right_sym.kind != .placeholder {
 | 
					 | 
				
			||||||
			c.error('cannot assign `$right_sym.name` to `$left.str()` of type `$left_sym.name`',
 | 
					 | 
				
			||||||
				right.position())
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue