diff options
author | dos-reis <gdr@axiomatics.org> | 2009-06-08 01:52:52 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2009-06-08 01:52:52 +0000 |
commit | a6bb66d5a34279f6b762cedc577155de6259ff30 (patch) | |
tree | f55617c55134a7ac63b8ca4569e09498042febf3 /src/interp/i-eval.boot | |
parent | f8913372cea43183d427cbe3d00c4967a840329b (diff) | |
download | open-axiom-a6bb66d5a34279f6b762cedc577155de6259ff30.tar.gz |
Fix SF/2799773
* interp/c-util.boot (diagnoseUnknownType): Diagnose duplicate
fields in Record or Union, or duplicate constants in Enumeration.
* interp/i-eval.boot (checkRecordOrUnionFields): New.
(evaluateType): Use it.
* testsuite/interpreter/sf-2799773.input: New.
Diffstat (limited to 'src/interp/i-eval.boot')
-rw-r--r-- | src/interp/i-eval.boot | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/interp/i-eval.boot b/src/interp/i-eval.boot index 91499994..527a36c3 100644 --- a/src/interp/i-eval.boot +++ b/src/interp/i-eval.boot @@ -1,5 +1,7 @@ -- Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -- All rights reserved. +-- Copyright (C) 2007-2009, Gabriel Dos Reis. +-- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are @@ -120,6 +122,13 @@ evaluateType0 form == IDENTP form and (constructor? form or form in $BuiltinConstructorNames) => throwEvalTypeMsg("S2IE0003",[form,form]) +++ Check for duplicate fields in a Union or Record domain form. +checkRecordOrUnionFields body == + for [[.,n,.],:fields] in tails body repeat + for field in fields | field is [.,=n,.] repeat + throwKeyedMsg("S2IL0030",[n]) + body + evaluateType form == -- Takes a parsed, unabbreviated type and evaluates it, replacing -- type valued variables with their values, and calling bottomUp @@ -142,11 +151,20 @@ evaluateType form == [op,:[evaluateType arg for arg in argl]] op='Union => argl and first argl is [x,.,.] and member(x,'(_: Declare)) => - [op,:[['_:,sel,evaluateType type] for ['_:,sel,type] in argl]] + [op, : checkRecordOrUnionFields + [[":",sel,evaluateType type] for ['_:,sel,type] in argl]] [op,:[evaluateType arg for arg in argl]] op='Record => - [op,:[['_:,sel,evaluateType type] for ['_:,sel,type] in argl]] - op='Enumeration => form + [op, : checkRecordOrUnionFields + [['_:,sel,evaluateType type] for ['_:,sel,type] in argl]] + op='Enumeration => + -- only symbols, and they must not be repeated. + for arg in argl repeat + IDENTP arg => nil + throwKeyedMsg("S2IL0031",nil) + for [arg,:args] in tails argl repeat + MEMQ(arg,args) => throwKeyedMsg("S2IL0032",[arg]) + form evaluateFormAsType form IDENTP form and niladicConstructorFromDB form => evaluateType [form] IDENTP form and (constructor? form or form in $BuiltinConstructorNames) => |