[pure-lang-svn] SF.net SVN: pure-lang: [283] pure/trunk/interpreter.cc
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-06-22 23:55:47
|
Revision: 283 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=283&view=rev Author: agraef Date: 2008-06-22 16:55:56 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Correction: Placing an "as" pattern at the spine of a function application causes trouble; forbid this. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-22 23:08:38 UTC (rev 282) +++ pure/trunk/interpreter.cc 2008-06-22 23:55:56 UTC (rev 283) @@ -1028,7 +1028,7 @@ case EXPR::APP: { if (p.len() >= MAXDEPTH) throw err("error in pattern (nesting too deep)"); - expr u = bind(vars, x.xval1(), 1, path(p, 0)), + expr u = bind(vars, x.xval1(), b, path(p, 0)), v = bind(vars, x.xval2(), 1, path(p, 1)); y = expr(u, v); break; @@ -1075,7 +1075,10 @@ if (sym.s != "_") { if (sym.prec < 10 || sym.fix == nullary) throw err("error in pattern (bad variable symbol '"+sym.s+"')"); - if (p.len() == 0 && !b || x.tag() > 0 && p.len() > 0 && p.last() == 0) + // Unless we're doing a pattern binding, subterms at the spine of a + // function application won't be available at runtime, so we forbid + // placing an "as" pattern there. + if (!b) throw err("error in pattern (misplaced variable '"+sym.s+"')"); env::iterator it = vars.find(sym.f); if (it != vars.end()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |