allow non snake_case fn names in imported fns
							parent
							
								
									faedebbb4e
								
							
						
					
					
						commit
						4ebf53c6e9
					
				|  | @ -309,18 +309,7 @@ fn (p mut Parser) fn_decl() { | ||||||
| 		f.name = p.check_name() | 		f.name = p.check_name() | ||||||
| 		f.is_c = true | 		f.is_c = true | ||||||
| 	} | 	} | ||||||
| 	else if !p.pref.translated { | 	orig_name := f.name | ||||||
| 		if contains_capital(f.name) && !p.fileis('view.v') && !p.is_vgen { |  | ||||||
| 			println('`$f.name`') |  | ||||||
| 			p.error('function names cannot contain uppercase letters, use snake_case instead') |  | ||||||
| 		} |  | ||||||
| 		if f.name[0] == `_` { |  | ||||||
| 			p.error('function names cannot start with `_`, use snake_case instead') |  | ||||||
| 		} |  | ||||||
| 		if f.name.contains('__') { |  | ||||||
| 			p.error('function names cannot contain double underscores, use single underscores instead') |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	// simple_name := f.name
 | 	// simple_name := f.name
 | ||||||
| 	// user.register() => User_register()
 | 	// user.register() => User_register()
 | ||||||
| 	has_receiver := receiver_typ.len > 0 | 	has_receiver := receiver_typ.len > 0 | ||||||
|  | @ -387,6 +376,19 @@ fn (p mut Parser) fn_decl() { | ||||||
| 	if is_fn_header { | 	if is_fn_header { | ||||||
| 		f.is_decl = true | 		f.is_decl = true | ||||||
| 	} | 	} | ||||||
|  | 	// Make sure the name is valid
 | ||||||
|  | 	if !is_c && !p.pref.translated && !is_fn_header { | ||||||
|  | 		if contains_capital(orig_name) && !p.fileis('view.v') && !p.is_vgen { | ||||||
|  | 			//println(orig_name)
 | ||||||
|  | 			p.error('function names cannot contain uppercase letters, use snake_case instead') | ||||||
|  | 		} | ||||||
|  | 		if f.name[0] == `_` { | ||||||
|  | 			p.error('function names cannot start with `_`, use snake_case instead') | ||||||
|  | 		} | ||||||
|  | 		if orig_name.contains('__') { | ||||||
|  | 			p.error('function names cannot contain double underscores, use single underscores instead') | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 	// `{` required only in normal function declarations
 | 	// `{` required only in normal function declarations
 | ||||||
| 	if !is_c && !p.is_vh && !is_fn_header { | 	if !is_c && !p.is_vh && !is_fn_header { | ||||||
| 		p.fspace() | 		p.fspace() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue