Changeset 811
- Timestamp:
- 12/22/10 04:01:22 (1 year ago)
- Files:
-
- trunk/src/mars.c (modified) (1 diff)
- trunk/src/template.c (modified) (3 diffs)
- trunk/src/template.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/mars.c
r737 r811 93 93 #endif 94 94 ; 95 version = "v2.05 1";95 version = "v2.052"; 96 96 global.structalign = 8; 97 97 trunk/src/template.c
r810 r811 1316 1316 * Recursive attempts are regarded as a constraint failure. 1317 1317 */ 1318 /* Previous should also store the scope, as instantiations along a different scope branch1319 * should not conflict1320 */1321 1318 int nmatches = 0; 1322 1319 for (Previous *p = previous; p; p = p->prev) … … 1324 1321 if (arrayObjectMatch(p->dedargs, dedargs, this, sc)) 1325 1322 { 1326 //printf("recursive, no match %p %s\n", this, this->toChars()); 1327 nmatches++; 1323 //printf("recursive, no match p->sc=%p %p %s\n", p->sc, this, this->toChars()); 1324 /* It must be a subscope of p->sc, other scope chains are not recursive 1325 * instantiations. 1326 */ 1327 for (Scope *scx = sc; scx; scx = scx->enclosing) 1328 { 1329 if (scx == p->sc) 1330 goto Lnomatch; 1331 } 1328 1332 } 1329 1333 /* BUG: should also check for ref param differences 1330 1334 */ 1331 1335 } 1332 /* Look for 2 matches at least, because sometimes semantic3() gets run causing what appears to1333 * be recursion but isn't.1334 * Template A's constraint instantiates B, B's semantic3() run includes something that has A in its constraint.1335 * Perhaps a better solution is to always defer semantic3() rather than doing it eagerly. The risk1336 * with that is what if semantic3() fails, but our constraint "succeeded"?1337 */1338 if (nmatches >= 2)1339 goto Lnomatch;1340 1336 1341 1337 Previous pr; 1342 1338 pr.prev = previous; 1339 pr.sc = paramscope; 1343 1340 pr.dedargs = dedargs; 1344 1341 previous = ≺ // add this to threaded list … … 3720 3717 void TemplateInstance::semantic(Scope *sc, Expressions *fargs) 3721 3718 { 3722 //printf("TemplateInstance::semantic('%s', this=%p, gag = %d )\n", toChars(), this, global.gag);3719 //printf("TemplateInstance::semantic('%s', this=%p, gag = %d, sc = %p)\n", toChars(), this, global.gag, sc); 3723 3720 if (global.errors && name != Id::AssociativeArray) 3724 3721 { trunk/src/template.h
r809 r811 67 67 struct Previous 68 68 { Previous *prev; 69 Scope *sc; 69 70 Objects *dedargs; 70 71 };
