Comments (1)
@frbrkoala Thanks for the bug report / feature request.
Just a quick update:
-
I was able to reproduce the issue. See the archive attached based on your example.
[email protected] -
The
$coll
exception is a runtime error which comes from an inconsistency between the Ergo type checker and the compiler. I think the intended behavior is for the suggested logic to fail type checking (with an error that the emit should be a singleton object). -
This is a perfectly valid and useful requirement imho. I think there might be two ways to support this. First being your suggestion i.e., allow
emit
to take either a single item or an array (which would make it polymorphic). Second might be to keep emit over single items but generalize whereemit
is allowed and notably allow it use insideforeach
. This would look something as follows (both options probably need work):
contract MyContractLogic over MyContract state State {
//Iterate through an array of vendors and emit an event for each of them
clause notifyVendors(request : NotifyVendorsReq) : NotifyVendorsRes emits VendorNotification[] {
foreach vendor in contract.vendors
return
emit VendorNotification {
code: request.notificationCode,
description: request.description,
vendor: vendor
};
return NotifyVendorsRes{ output: "Received " ++ request.notificationCode ++ " " ++ request.description ++ " and sent notification to vendors " ++ toString(contract.vendors) }
}
}
from ergo.
Related Issues (20)
- Document and Clarify Determinism of Ergo HOT 1
- Amounts formatting using Ergo `as` expression isn't aligned with that in the new parser HOT 1
- Extraneous double-quotes rendered in 'foreach' Ergo Expression HOT 6
- Refactor, simplify and clean up Engine API
- Formulas which return a string value are quoted HOT 1
- types definitions HOT 1
- REPL does not return any response HOT 5
- pass arguments to contract init HOT 5
- Migrate CI/CD to GitHub Actions HOT 1
- Typo for the link in Readme
- Flocq source dependency for Ergo 0.21 doesn't build on recent MacOS HOT 2
- GitHub Actions code coverage step doesn't report properly on Windows
- Ergo 0.22 CLI is broken, looking for moment library
- durationAs calculation error minutes to hours HOT 2
- Optional DateTime always return TRUE for `some(myDate)` HOT 3
- Cannot build from sources due to incompatible coq-jsast.3.0.0
- Maintainers Needed HOT 4
- ergo compile issue - Unknown arguments: ./model/model.cto, ./logic/logic.ergo
- Depreciation and not recognized errors HOT 1
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 ergo.