Comments (7)
Sounds good. Yes, I guess users need to declare the exceptions. Having our own synonyms, including a constructor for Exception("...") might be useful.
from stainless.
Perhaps a clean way to do it would be to define in stainless.lang:
@extern
def throwReached[A](s: String): A
require(false)
???
and then replace throw E
with a call to throwReached("E")
from stainless.
One advantage of using such exception instead of assert is that, if ghost code is eliminated but Stainless function is used from unverified Scala code that does not meet the require clauses that Stainless assumed, then errors thrown will be easier to react to and classify than assertions.
from stainless.
If we address this with a PR, we should simultaneously add the Try
type
https://github.com/scala/scala/blob/v2.13.3/src/library/scala/util/Try.scala#L64
To handle exception handling outside code (such as I/O) the users should write
@extern
def myMethods(x:A): Try[B] = {
Try(BufferedMuffeledReaderWriter(...))
}
where Try
is defined in stainless.lang
from stainless.
We can hopefully also accept Exception as a super class (e.g. define it in stainless.lang) and permit its subclasses.
Here users would have to redefine their own exception classes to use subclasses, right?
For example, to use IllegalArgumentException
, one would have to define her own IllegalArgumentException
that extends stainless.lang.Exception
. Or am I missing something?
from stainless.
there was a tentative apparently.
from stainless.
This compiles, once I removed the check in FragmentChecker
:
import stainless.lang.Exception
class IllegalArgumentException(msg: String) extends Exception
object ThrowTest {
def f(): Unit =
throw new IllegalArgumentException("This is an exception")
}
Now I'll be working on the extraction of throw
from stainless.
Related Issues (20)
- Crash in Inox type checker when using freshCopy HOT 1
- Failure of postcondition shown as failure of the assertion in the branch
- Inline functions that do mutation rejected as ghost HOT 3
- Inconsistent positions for postcondition HOT 1
- Equalities to be rejected: Double, functions, allocatable non-case classes, type vars HOT 4
- `AntiAliasing` not updating targets for `val` fields HOT 2
- Why is `ConcTree.Empty` not a `case object`? HOT 1
- Unsoundness when using `swap` due to AntiAliasing not flagging HOT 9
- "publicly opaque" concept would be useful when working with laws HOT 1
- `AntiAliasing` does not update local aliasing information after replacement
- Incorrect transformation of inner functions mutating a local variable
- MethodLifting reporting when subclasses have preconditions
- Error reporting from alias analysis
- PrimitiveSize functions should not be generated when termination checking is off?
- Treat the `erased` soft keyword as Stainless `@ghost`
- Well-formedness check failure when operating on an `Array` type alias
- Incorrect usage of `old` when it is not
- Unpredictable reporting on circular type classes
- StackOverflowError during Measure Inference
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stainless.