[vala] Do not use char for non-ASCII character literals
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Do not use char for non-ASCII character literals
- Date: Tue, 29 Sep 2009 20:38:07 +0000 (UTC)
commit b0c03c0e78968982cd27a61d732c5ff758bb5d20
Author: Jürg Billeter <j bitron ch>
Date: Tue Sep 29 22:37:20 2009 +0200
Do not use char for non-ASCII character literals
Fixes bug 596785.
tests/Makefile.am | 1 +
tests/basic-types/bug596785.vala | 4 ++++
vala/valacharacterliteral.vala | 6 +++++-
3 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 907f133..41213ce 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,6 +21,7 @@ TESTS = \
basic-types/arrays.vala \
basic-types/pointers.vala \
basic-types/bug596637.vala \
+ basic-types/bug596785.vala \
namespaces.vala \
methods/lambda.vala \
methods/closures.vala \
diff --git a/tests/basic-types/bug596785.vala b/tests/basic-types/bug596785.vala
new file mode 100644
index 0000000..7afb21a
--- /dev/null
+++ b/tests/basic-types/bug596785.vala
@@ -0,0 +1,4 @@
+void main () {
+ var c = 'â?¬';
+ assert (c == 'â?¬');
+}
diff --git a/vala/valacharacterliteral.vala b/vala/valacharacterliteral.vala
index 1d33c92..f671535 100644
--- a/vala/valacharacterliteral.vala
+++ b/vala/valacharacterliteral.vala
@@ -85,7 +85,11 @@ public class Vala.CharacterLiteral : Literal {
checked = true;
- value_type = new IntegerType ((Struct) analyzer.root_symbol.scope.lookup ("char"));
+ if (get_char () < 128) {
+ value_type = new IntegerType ((Struct) analyzer.root_symbol.scope.lookup ("char"));
+ } else {
+ value_type = new IntegerType ((Struct) analyzer.root_symbol.scope.lookup ("unichar"));
+ }
return !error;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]