#1384 [fansh] Variables are always nullable

vkuzkokov Thu 13 Jan 2011

Why?

fansh> x := "hi"
hi
fansh> [x].typeof
sys::Str?[]

vkuzkokov Thu 13 Jan 2011

BTW, with

--- a/src/fansh/fan/Evaluator.fan       Thu Jan 06 15:29:23 2011 -0500
+++ b/src/fansh/fan/Evaluator.fan       Thu Jan 13 15:59:27 2011 +0600
@@ -138,7 +140,7 @@
   private Str typeSig(Type t)
   {
     // handle parameterized generics
-    if (!t.params.isEmpty) return t.toNullable.signature
+    if (!t.params.isEmpty) return t.signature

     // FFI types aren't qualified
     if (t.signature.startsWith("["))
@@ -152,7 +154,7 @@
     }

     // use qualified nullable type
-    return t.toNullable.signature
+    return t.signature
   }

   private Void compile(Str source)

things work just fine to me.

helium Thu 13 Jan 2011

That's strange

["hi"].typeof -> sys::Str[]

x := "hi"
x.typeof      -> sys::Str
[x].typeof    -> sys::Str?[]

Probably a bug.

brian Thu 13 Jan 2011

For some reason when we added nullables I found it inconvient to not have the fansh have everything be nullable.

Maybe that isn't such a great idea, especially if you are trying to learn about nullable types.

I don't have any problem change that behavior?

Anyone disagree with making fansh maintain nullability of original declaration?

brian Tue 1 Mar 2011

Promoted to ticket #1384 and assigned to brian

brian Wed 2 Mar 2011

Ticket resolved in 1.0.58

Not sure why I make those locals nullable in first place, but I tested this change and didn't see any negative effects.

Login or Signup to reply.