Skip to content

Instantly share code, notes, and snippets.

@kmizu
Created August 10, 2019 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmizu/2fc7245b6769b1aac27359106e2c8b45 to your computer and use it in GitHub Desktop.
Save kmizu/2fc7245b6769b1aac27359106e2c8b45 to your computer and use it in GitHub Desktop.
Nullability in Nice (0.9.13)
[Mizushima]$ cat hello1/hello1.nice
import java.util.*;
void main(String[] args) {
let value = System.getProperty("hello");
assert value != null;
System.out.println(value.length());
}
~/work
[Mizushima]$ nicec.bat hello1
nice.lang: parsing
hello1: parsing
hello1: typechecking
hello1: generating code
hello1: linking
~/work
[Mizushima]$ java -Dhello=Hello hello1.fun
5
~/work
[Mizushima]$ java -Dhello=Hell hello1.fun
4
~/work
[Mizushima]$ java hello1.fun
Exception in thread "main" java.lang.NullPointerException
at hello1.fun.main(Unknown Source)
~/work
[Mizushima]$ ls hello2
./ ../ hello2.nice
~/work
[Mizushima]$ nicec.bat hello2
nice.lang: parsing
hello2: parsing
hello2: typechecking
~\work\hello2\hello2.nice: line 5, column 28:
No possible call for length.
Arguments: (?java.lang.String)
Possibilities:
<T> nice.lang.int length(T[])
nice.lang.long length(java.io.File)
nice.lang.int length(java.lang.CharSequence)
compilation failed with 1 error
~/work
[Mizushima]$ cat hello2/hello2.nice
import java.util.*;
void main(String[] args) {
let value = System.getProperty("hello");
System.out.println(value.length());
}
[Mizushima]$ nicec.bat --version
Nice compiler version 0.9.13 (build 2007.12.16, 12:24:52 UTC)
Compiled using JDK 1.4.2
Copyright (C) 2003 Daniel Bonniot
Visit the Nice homepage: http://nice.sourceforge.net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment