Commit a8c239fe authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

check type of variable initializer

2008-01-22  Juerg Billeter  <j@bitron.ch>

	* vala/valasemanticanalyzer.vala: check type of variable initializer

	* gee/hashmap.vala, gee/hashset.vala, vala/valasymbol.vala: fix invalid
	  variable initializers

svn path=/trunk/; revision=884
parent ef79c891
2008-01-22 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: check type of variable initializer
* gee/hashmap.vala, gee/hashset.vala, vala/valasymbol.vala: fix invalid
variable initializers
2008-01-22 Jürg Billeter <j@bitron.ch>
* vapi/packages/gdk-pixbuf-2.0/, vapi/packages/gdk-2.0/,
......
......@@ -141,7 +141,7 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
private void resize () {
if ((_array_size >= 3 * _nnodes && _array_size >= MIN_SIZE) ||
(3 * _array_size <= _nnodes && _array_size < MAX_SIZE)) {
int new_array_size = SpacedPrimes.closest (_nnodes);
int new_array_size = (int) SpacedPrimes.closest (_nnodes);
new_array_size = new_array_size.clamp (MIN_SIZE, MAX_SIZE);
Node<K,V>[] new_nodes = new Node<K,V>[new_array_size];
......
......@@ -126,7 +126,7 @@ public class Gee.HashSet<G> : Object, Iterable<G>, Collection<G>, Set<G> {
private void resize () {
if ((_array_size >= 3 * _nnodes && _array_size >= MIN_SIZE) ||
(3 * _array_size <= _nnodes && _array_size < MAX_SIZE)) {
int new_array_size = SpacedPrimes.closest (_nnodes);
int new_array_size = (int) SpacedPrimes.closest (_nnodes);
new_array_size = new_array_size.clamp (MIN_SIZE, MAX_SIZE);
Node<G>[] new_nodes = new Node<G>[new_array_size];
......
......@@ -738,6 +738,12 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
}
if (!decl.initializer.static_type.compatible (decl.type_reference)) {
decl.error = true;
Report.error (decl.source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf (decl.initializer.static_type.to_string (), decl.type_reference.to_string ()));
return;
}
if (decl.initializer.static_type.transfers_ownership) {
/* rhs transfers ownership of the expression */
if (!(decl.type_reference is PointerType) && !decl.type_reference.takes_ownership) {
......
/* valasymbol.vala
*
* Copyright (C) 2006-2007 Jürg Billeter
* Copyright (C) 2006-2008 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -202,7 +202,7 @@ public abstract class Vala.Symbol : CodeNode {
if (!prev_upper || (i.len () >= 2 && !next_upper)) {
/* previous character wasn't upper case or
* next character isn't upper case*/
int len = result.str.len ();
long len = result.str.len ();
if (len != 1 && result.str.offset (len - 2).get_char () != '_') {
/* we're not creating 1 character words */
result.append_c ('_');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment