Skip to content

Commit 99a3156

Browse files
committed
More
1 parent 7e1c274 commit 99a3156

2 files changed

Lines changed: 25 additions & 23 deletions

File tree

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ ethos 0.1.2 prerelease
55

66
- Change the execution semantics when a program takes an unevalated term as an argument. In particular, we do not call user provided programs and oracles when at least argument could not be evaluated. This change was made to make errors more intuitive. Note this changes the semantics of programs that previously relied on being called on unevaluated terms.
77
- User programs, user oracles, and builtin operators that are unapplied are now considered unevaluated. This makes the type checker more strict and disallows passing them as arguments to other programs, which previously led to undefined behavior.
8-
- Changes the interface of `declare-parameterized-const`. In particular, the parameters of a parameterized constants are no longer assumed to be implicit, and are explicit by default. The `:implicit` attribute can be used on all parameters to recover the previous behavior. Other attributes such as `:opaque` and `:requires` can be used on parameters to this command.
8+
- Changes the interface of `declare-parameterized-const`. In particular, the parameters of a parameterized constants are no longer assumed to be implicit, and are explicit by default. The `:implicit` attribute can be used on all parameters to recover the previous behavior. Other attributes such as `:opaque` and `:requires` can now be used on parameters to this command.
99
- Remove support for the explicit parameter annotation `eo::_`, which was used to provide annotations for implicit arguments to parameterized constants.
1010
- Changed the semantics of pairwise and chainable operators for a single argument, which now reduces to the neutral element of the combining operator instead of a parse error.
1111
- The operator `eo::typeof` now fails to evaluate if the type of the given term is not ground.
1212

13-
- Adds support for the SMT-LIB `as` annotations for ambiguous datatype constructors, i.e. those whose return type cannot be inferred from its argument types. Following SMT-LIB convention, ambiguous datatype constructors are expected to be annotated with their *return* type using `as`, which internally is treated as a type argument to the constructor.
13+
- Adds support for the SMT-LIB `as` annotations for ambiguous functions and constants, i.e. those whose return type cannot be inferred from their argument types. Following SMT-LIB convention, ambiguous functions and constants are expected to be annotated with their *return* type using `as`, which internally is treated as a type argument to the function. This policy is applied both for ambiguous datatype constructors and ambiguous functions and constants declared with `declare-parameterized-const`.
1414
- The semantics for `eo::dt_constructors` is extended for instantiated parametric datatypes. For example calling `eo::dt_constructors` on `(List Int)` returns the list containing `cons` and `(as nil (List Int))`.
1515
- The semantics for `eo::dt_selectors` is extended for annotated constructors. For example calling `eo::dt_selectors` on `(as nil (List Int))` returns the empty list.
1616

src/cmd_parser.cpp

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -230,30 +230,32 @@ bool CmdParser::parseNextCommand()
230230
}
231231
t = d_state.mkFunctionType({qt}, t);
232232
}
233-
if (tok==Token::DECLARE_PARAMETERIZED_CONST)
233+
}
234+
if (tok==Token::DECLARE_PARAMETERIZED_CONST)
235+
{
236+
// If this is an ambiguous function, we add (Quote T)
237+
// as the first argument type. We only need to test if we are parsing
238+
// the command declare-parameterized-const.
239+
std::pair<std::vector<Expr>, Expr> ft = t.getFunctionType();
240+
std::vector<Expr> argTypes = ft.first;
241+
argTypes.insert(argTypes.end(), opaqueArgs.begin(), opaqueArgs.end());
242+
Expr tup = d_state.mkExpr(Kind::TUPLE, argTypes);
243+
std::vector<Expr> pargs = Expr::getVariables(tup);
244+
Expr fv = d_eparser.findFreeVar(ft.second, pargs);
245+
Trace("ajr-temp") << "Looking for free variable in " << ft.second << " returned " << fv << std::endl;
246+
if (!fv.isNull())
234247
{
235-
// if this is an ambiguous datatype constructor, we add (Quote T)
236-
// as the first argument type.
237-
std::pair<std::vector<Expr>, Expr> ft = t.getFunctionType();
238-
std::vector<Expr> argTypes = ft.first;
239-
argTypes.insert(argTypes.end(), opaqueArgs.begin(), opaqueArgs.end());
240-
Expr tup = d_state.mkExpr(Kind::TUPLE, argTypes);
241-
std::vector<Expr> pargs = Expr::getVariables(tup);
242-
Expr fv = d_eparser.findFreeVar(ft.second, pargs);
243-
if (!fv.isNull())
248+
if (ck!=Attr::NONE)
244249
{
245-
if (ck!=Attr::NONE)
246-
{
247-
d_lex.parseError("Ambiguous functions cannot have attributes");
248-
}
249-
else if(!opaqueArgs.empty())
250-
{
251-
d_lex.parseError("Ambiguous functions cannot have opaque arguments");
252-
}
253-
Expr qt = d_state.mkQuoteType(ft.second);
254-
t = d_state.mkFunctionType({qt}, t);
255-
ck = Attr::AMB;
250+
d_lex.parseError("Ambiguous functions cannot have attributes");
251+
}
252+
else if(!opaqueArgs.empty())
253+
{
254+
d_lex.parseError("Ambiguous functions cannot have opaque arguments");
256255
}
256+
Expr qt = d_state.mkQuoteType(ft.second);
257+
t = d_state.mkFunctionType({qt}, t);
258+
ck = Attr::AMB;
257259
}
258260
}
259261
// now process remainder of map

0 commit comments

Comments
 (0)