TADS Bug Database

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000180TADS 3Compilerpublic2012-12-27 18:122013-04-23 17:36
ReporterNRTurner 
Assigned ToMichael Roberts 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformMacintoshOSMacOSOS VersionX
Summary0000180: Preprocessor failure
DescriptionThe preprocessor garbles a macro expansion. See attached file. A workaround is to define a local variable buffer for text and replace that macro argument in the body of the macro.
TagsNo tags attached.
Fixed In Version3.1.3
Attached Files? file icon 1.t [^] (1,335 bytes) 2012-12-27 18:12
? file icon 2.t [^] (957 bytes) 2013-04-23 14:18

- Relationships

-  Notes
(0000296)
NRTurner (reporter)
2012-12-27 18:15
edited on: 2012-12-30 05:38

One of the lines cutoff by the preprocessor is quoted in the file. (It's all angle brackets which would come out as garbage here).

(0000323)
Michael Roberts (administrator)
2013-04-22 19:19

The file seems to have a bunch of stuff in it - could you please point out which specific line contains the problem, and the expected and actual outputs? Thanks.
(0000326)
NRTurner (reporter)
2013-04-23 14:32

Okay I've cut it down a little (2.t). The relevant line is the macro:

The relevant line is the macro:

#define _H(num,align,text) if (align) return '<h<<toString(num)>> align=<<align>>\><<text>></h<<toString(num)>>>'; 
\
    return make_htmlTag('h'+toString(num),text);


Compiler output:

$ t3make
TADS Compiler 3.1.2 Copyright 1999, 2012 Michael J. Roberts
    Files to build: 9
    symbol_export 2.t -> obj/2.t3s
2.t(20): error: expected integer, string, symbol, '[', or '(', but found ""
2.t(20): error: expected integer, string, symbol, '[', or '(', but found ""
2.t(20): error: expected ')' at end of argument list, but found ";"
2.t(20): error: expected ')' at end of argument list, but found ";"
Errors: 4
Warnings: 0

Selected output for the preprocessor (only lines matching "h1" - the function in which the _H macro expansion occurs):

h1(align:?,text) {if (align) return '<h<<toString(1)>> align=<<align>>\><<text>></h<<toString(1)>>>'; 	
return make_htmlTag('h'+toString(),?0
    local x = h1('Title');


I believe the problem is the RETURN statement where the end of the line has been cutoff in the macro expansion.
The expected RETURN statement is something like: (where text has the value 'Title')
 return make_htmlTag('h'+toString(1),text);
(0000332)
Michael Roberts (administrator)
2013-04-23 17:34
edited on: 2013-04-23 17:36

Thanks for the added info - that helped narrow it down.

Here's the minimal test case:

#define M(a,b) '<< b >><<9>>' a
M(1,2)

The trigger is that the expansion uses the *last* macro argument in a string embedding which has another embedding following; any mentions of a macro argument following that are not expanded properly.

I've fixed this for the next update. For a temporary workaround, the only good approach I see is to rewrite the macro using the equivalent explicit string concatenation instead of embeddings:

#define M(a,b) ''+(b)+'9' a


- Issue History
Date Modified Username Field Change
2012-12-27 18:12 NRTurner New Issue
2012-12-27 18:12 NRTurner File Added: 1.t
2012-12-27 18:15 NRTurner Note Added: 0000296
2012-12-30 05:38 NRTurner Note Edited: 0000296
2013-04-22 19:19 Michael Roberts Note Added: 0000323
2013-04-22 19:19 Michael Roberts Status new => feedback
2013-04-23 14:18 NRTurner File Added: 2.t
2013-04-23 14:32 NRTurner Note Added: 0000326
2013-04-23 14:32 NRTurner Status feedback => new
2013-04-23 17:34 Michael Roberts Fixed In Version => 3.1.3
2013-04-23 17:34 Michael Roberts Note Added: 0000332
2013-04-23 17:34 Michael Roberts Assigned To => Michael Roberts
2013-04-23 17:34 Michael Roberts Status new => resolved
2013-04-23 17:34 Michael Roberts Resolution open => fixed
2013-04-23 17:34 Michael Roberts Note Edited: 0000332 View Revisions
2013-04-23 17:35 Michael Roberts Note Edited: 0000332 View Revisions
2013-04-23 17:35 Michael Roberts Note Edited: 0000332 View Revisions
2013-04-23 17:36 Michael Roberts Note Edited: 0000332 View Revisions


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker