[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xsmith-dev] XSmith questions

Hi everyone,

I just started using XSmith. I don’t think I grok the framework yet, so I would really appreciate it if anyone could help me!

1) While I understand that dynamically typed language should specify type-info to generate programs that don’t cause runtime type mismatch, I find it weird that types are very integral to the framework. For example, binder-info seems to presuppose that declaration AST nodes will have type information in it.

On one hand, that’s strictly speaking not the case for many languages.

On the other hand, I can understand that the specified grammar here doesn’t need to correspond to the actual language grammar. So let’s just add the type field into the AST node. But this raises another question: how do I know which other AST nodes will require additional type information as well?

2) As far as I can see, all declaration nodes have types to be that of the _expression_ it contains. Again, I find this weird since declaration in most languages is a statement, not an _expression_. I tried fixing this by modifying the “Another Small Example with Variables” example to:

 [Definition [no-return-type (λ (n t) (hash '_expression_ (fresh-type-variable)))]]
 [LetStar [(fresh-type-variable)
           (λ (n t) (hash 'definitions (λ (cn) no-return-type)
                          'sideEs (λ (cn) (fresh-type-variable))
                          '_expression_ t))]]

where no-return-type is from xsmith/canned-components. The generation errors with with:

unify!: subtype-unify!: can't unify these types: #<type-variable (#<range:#<no-return-type>-#<no-return-type>>)> and #<int>

In most examples that I saw, declarations are hoisted at the very top of function / block / program. I think the no-return-type is particularly going to be a problem when I want to allow declarations and statements to interleave, since statements will be assigned a unique type (like no-return-type), while declarations can’t do the same.

3) How do I debug when XSmith simply hangs and doesn’t output anything? It looks like the problems I encountered are with types, since if I relax the constraints, it can generate programs without any problem (though the generated programs are incorrect, as expected).

4) In xsmith/canned-components, there are several predefined types, but the module only exports constructors, not accessors. What would be the best way to extract information from it? unify!?