usethesource / rascal

The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
http://www.rascal-mpl.org
Other
406 stars 78 forks source link

undefined field on locations crashed compiled console #965

Open jurgenvinju opened 8 years ago

jurgenvinju commented 8 years ago
rascal>|std:///List.rsc|.ls

unexpected error: null
java.lang.NullPointerException
        at org.rascalmpl.uri.URIResolverRegistry.list(URIResolverRegistry.java:418)
        at org.rascalmpl.library.experiments.Compiler.RVM.Interpreter.RascalPrimitive$381.execute2(RascalPrimitive.java:6717)
        at .ConsoleInput$Compiled.ConsoleInput\main()#0(Unknown Source)
        at .ConsoleInput$Compiled.dynRun(Unknown Source)

This should throw a (catchable) Rascal exception for a undefined field instead of a null pointer exception.

DavyLandman commented 8 years ago

shouldn't it throw an exception that the .ls field only works if isDirectory(loc) is true? as in, the field exists, it just shoudln't be called on non directory things..

Or perhaps we should in that case always return an empty list? how do other libraries handle this?

DavyLandman commented 8 years ago

ah, java throws an NotDirectoryException for the java8 style api: https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#newDirectoryStream-java.nio.file.Path-