I'm running into a problem with inconsistent type names returned by swig_type() when used with templates. I'm using swig with Lua, but don't know if the bug is Lua-specific. I've created a simple example to demonstrate the problem. In the example, I use a typedef and define two template classes, one of which, 'Point' refers to the other, 'Dim'. This reference seems to needed to cause the problem. The result is that composite type name is truncated, so that only the base type is given.  This is happening with the current swig svn head and Lua 5.1.1.

Here is the output from my test:

---------------------- output of runme.lua ----------------
$ lua runme.lua
Creating some objects:
    Created dim userdata: 003DA488

Here are their swig_types():
    iDim = (Dim<int > *)

Guess I'll clean up now

The expected output should be:

    iDim = (Dim<int > *|Dim<s32 > *)

If I comment out the template instantiation for my Point class, it gives the expected result from swig_type().  Here are the example files:

---------------------- example.h -----------------------------
#ifndef example_h
#define example_h

typedef int s32;

template<class T> class Dim {
    Dim( T w_, T h_ )
    : w(w_), h(h_)
    virtual ~Dim() {}
    T  w, h;  

template<class T> class Point {
    Point( T x_, T y_ )
    : x(x_), y(y_)
    Point<T> operator+( const Dim<T>& other ) const
        return Point<T>( x + other.w, y + other.h );
    virtual ~Point() {}
    T  x, y;  


---------------------- example.i -----------------------------
/* File : example.i */
%module example

#include "example.h"

/* Let's just grab the original header file here */
%include "example.h"

%template(s32Dim) Dim<s32>;
%template(s32Point) Point<s32>;   // you can comment this out to make the bug go away

---------------------- runme.lua -----------------------------
-- file: runme.lua

-- This file illustrates template interface generated
-- by SWIG.

---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -- lua5.0 doesnt have a nice way to do this
    lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
    -- lua 5.1 does

----- Object creation -----

print("Creating some objects:")
id = example.s32Dim(10, -10)
print("    Created dim", id)

----- swig_type -----
print("\nHere are their swig_types():")
print(string.format("    iDim = (%s)", swig_type(id)))

print("\nGuess I'll clean up now")

-- Note: this invokes the virtual destructor
id = nil

-- call gc to make sure they are collected

print "Goodbye"