Browse Source

Minor fixes

gingerBill 7 years ago
parent
commit
597fb452b1
4 changed files with 8 additions and 3 deletions
  1. 4 1
      examples/demo/demo.odin
  2. 2 0
      src/check_decl.cpp
  3. 1 1
      src/check_stmt.cpp
  4. 1 1
      src/tokenizer.cpp

+ 4 - 1
examples/demo/demo.odin

@@ -492,6 +492,9 @@ parametric_polymorphism :: proc() {
 
 
 	{ // Polymorphic names
 	{ // Polymorphic names
 		foo :: proc($N: $I, $T: typeid) -> (res: [N]T) {
 		foo :: proc($N: $I, $T: typeid) -> (res: [N]T) {
+			// `N` is the constant value passed
+			// `I` is the type of N
+			// `T` is the type passed
 			fmt.printf("Generating an array of type %v from the value %v of type %v\n",
 			fmt.printf("Generating an array of type %v from the value %v of type %v\n",
 			           typeid_of(type_of(res)), N, typeid_of(I));
 			           typeid_of(type_of(res)), N, typeid_of(I));
 			for i in 0..N-1 {
 			for i in 0..N-1 {
@@ -790,7 +793,7 @@ bit_set_type :: proc() {
 		assert(size_of(x) == size_of(u32));
 		assert(size_of(x) == size_of(u32));
 		y: bit_set[0..8; u16];
 		y: bit_set[0..8; u16];
 		fmt.println(typeid_of(type_of(x))); // bit_set[A..Z]
 		fmt.println(typeid_of(type_of(x))); // bit_set[A..Z]
-		fmt.println(typeid_of(type_of(y))); // bit_set[0..8l u16]
+		fmt.println(typeid_of(type_of(y))); // bit_set[0..8; u16]
 
 
 		incl(&x, 'F');
 		incl(&x, 'F');
 		assert('F' in x);
 		assert('F' in x);

+ 2 - 0
src/check_decl.cpp

@@ -1024,6 +1024,7 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
 	}
 	}
 
 
 	ast_node(bs, BlockStmt, body);
 	ast_node(bs, BlockStmt, body);
+	// check_open_scope(ctx, body);
 	check_stmt_list(ctx, bs->stmts, Stmt_CheckScopeDecls);
 	check_stmt_list(ctx, bs->stmts, Stmt_CheckScopeDecls);
 	if (type->Proc.result_count > 0) {
 	if (type->Proc.result_count > 0) {
 		if (!check_is_terminating(body)) {
 		if (!check_is_terminating(body)) {
@@ -1035,6 +1036,7 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
 			}
 			}
 		}
 		}
 	}
 	}
+	// check_close_scope(ctx);
 
 
 	check_scope_usage(ctx->checker, ctx->scope);
 	check_scope_usage(ctx->checker, ctx->scope);
 
 

+ 1 - 1
src/check_stmt.cpp

@@ -1337,7 +1337,7 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
 			}
 			}
 
 
 			Type *type = x.type;
 			Type *type = x.type;
-			if (!is_type_integer(type) && !is_type_float(type) && !is_type_pointer(type)) {
+			if (!is_type_integer(type) && !is_type_float(type) && !is_type_pointer(type) && !is_type_enum(type)) {
 				error(ie->op, "Only numerical and pointer types are allowed within interval expressions");
 				error(ie->op, "Only numerical and pointer types are allowed within interval expressions");
 				goto skip_expr;
 				goto skip_expr;
 			}
 			}

+ 1 - 1
src/tokenizer.cpp

@@ -76,7 +76,7 @@ TOKEN_KIND(Token__ComparisonEnd, ""), \
 	TOKEN_KIND(Token_Semicolon,     ";"),   \
 	TOKEN_KIND(Token_Semicolon,     ";"),   \
 	TOKEN_KIND(Token_Period,        "."),   \
 	TOKEN_KIND(Token_Period,        "."),   \
 	TOKEN_KIND(Token_Comma,         ","),   \
 	TOKEN_KIND(Token_Comma,         ","),   \
-	TOKEN_KIND(Token_Ellipsis,    ".."),  \
+	TOKEN_KIND(Token_Ellipsis,      ".."),  \
 	TOKEN_KIND(Token_BackSlash,     "\\"),  \
 	TOKEN_KIND(Token_BackSlash,     "\\"),  \
 TOKEN_KIND(Token__OperatorEnd, ""), \
 TOKEN_KIND(Token__OperatorEnd, ""), \
 \
 \