v2: handle unresolved consts
parent
bf5ed5e451
commit
d5f90ef64b
|
@ -384,6 +384,13 @@ pub fn (c &Checker) expr(node ast.Expr) table.Type {
|
|||
}
|
||||
return info.typ
|
||||
}
|
||||
// Handle indents with unresolved types during the parsing step
|
||||
// (declared after first usage)
|
||||
else if it.kind == .blank_ident {
|
||||
if constant := c.table.find_const(it.name) {
|
||||
return constant.typ
|
||||
}
|
||||
}
|
||||
return table.void_type
|
||||
}
|
||||
ast.BoolLiteral {
|
||||
|
|
|
@ -33,7 +33,7 @@ fn test_c_files() {
|
|||
}
|
||||
else {
|
||||
eprintln('${term_fail} ${i}')
|
||||
eprintln('${path}: got\n{$res}')
|
||||
eprintln('${path}: got\n$res')
|
||||
assert false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ void variadic(variadic_int a);
|
|||
void ensure_cap(int required, int cap);
|
||||
void println(string s);
|
||||
void matches();
|
||||
|
||||
void end();
|
||||
int pi = 3;
|
||||
|
||||
typedef struct {
|
||||
|
@ -30,7 +30,6 @@ int main() {
|
|||
|
||||
void foo(int a) {
|
||||
while (true) {
|
||||
|
||||
}
|
||||
for (int i = 0;
|
||||
i < 10; i++;
|
||||
|
@ -92,6 +91,7 @@ multi_return_int_string multi_return() {
|
|||
}
|
||||
|
||||
void variadic(variadic_int a) {
|
||||
int x = path_sep;
|
||||
}
|
||||
|
||||
void ensure_cap(int required, int cap) {
|
||||
|
@ -116,5 +116,8 @@ void matches() {
|
|||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
int path_sep = 10;
|
||||
|
||||
void end() {
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ fn multi_return() (int,string) {
|
|||
}
|
||||
|
||||
fn variadic(a ...int) {
|
||||
//a := path_sep
|
||||
x := path_sep
|
||||
}
|
||||
|
||||
fn ensure_cap(required int, cap int) {
|
||||
|
@ -120,10 +120,12 @@ fn matches() {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
const (
|
||||
path_sep = 10
|
||||
)
|
||||
*/
|
||||
|
||||
fn end() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -437,8 +437,12 @@ pub fn (p mut Parser) parse_ident(is_c bool) (ast.Ident,table.Type) {
|
|||
// Function object (not a call), e.g. `onclick(my_click)`
|
||||
p.table.find_fn(name) or {
|
||||
// ident.info = ast.IdentVar
|
||||
p.error('parse_ident: unknown identifier `$name`')
|
||||
exit(0)
|
||||
node = ast.Ident{
|
||||
kind: .blank_ident
|
||||
name: name
|
||||
}
|
||||
return node,typ
|
||||
// p.error('parse_ident: unknown identifier `$name`')
|
||||
}
|
||||
// p.next()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue